Skip to content

ERB#def_class, def_module, def_method のサンプルを実行可能に#3045

Merged
znz merged 2 commits into
rurema:masterfrom
scivola:patch-1
Jul 10, 2026
Merged

ERB#def_class, def_module, def_method のサンプルを実行可能に#3045
znz merged 2 commits into
rurema:masterfrom
scivola:patch-1

Conversation

@scivola

@scivola scivola commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

#2196
を解決します。
この issue は ERB#def_class についてのものですが,def_module, def_method も合わせて修正しました。

修正のポイントは

  • コピペで実行可能にする
  • 外部ファイルを使わない
  • filename を触らない
  • クラス名は rdoc 版を参考にする

といったところです。

rurema#2196
を解決します。
この issue は ERB#def_class についてのものですが,def_module, def_method も合わせて修正しました。

修正のポイントは

* コピペで実行可能にする
* 外部ファイルを使わない
* filename を触らない
* クラス名は rdoc 版を参考にする

といったところです。
Comment thread manual/api/erb.md Outdated
Comment on lines +317 to +319
例:

`````
require 'erb'
erb = ERB.new(script)
erb.def_method(MyClass, 'foo(bar)', 'foo.erb')
`````
```rb title="例"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rb → ruby の修正と「例」が二重になるのを修正。

Suggested change
例:
`````
require 'erb'
erb = ERB.new(script)
erb.def_method(MyClass, 'foo(bar)', 'foo.erb')
`````
```rb title="例"
```ruby title="例"

Comment thread manual/api/erb.md
arg2: <%= @arg2 %>
ERB

MySubClass = erb.def_class(MyBaseClass, :render)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの render だけ文字列ではなく Symbol になっているのが不統一ですが、元の rdoc がそうなっているようなので、そのままにしておきます。

@znz znz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。

@znz znz merged commit e8b487d into rurema:master Jul 10, 2026
9 checks passed
@scivola scivola deleted the patch-1 branch July 10, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants