るりまサーチ

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.379秒)
トップページ > クエリ:_builtin[x] > ライブラリ:ビルトイン[x] > クエリ:E[x] > クエリ:import_methods[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

検索結果

Refinement#import_methods(*modules) -> self (32221.0)

モジュールからメソッドをインポートします。

...モジュールからメソッドをインポートします。

Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。

メソッドをコピーするため、Rubyコードで...
...//emlist[][ruby]{
module StrUtils
def indent(level)
' ' * level + self
e
nd
e
nd

module M
refine String do
import_methods
StrUtils
e
nd
e
nd

using M
p "foo".indent(3) # => " foo"

module M
refine String do
import_methods
Enumerable
# Can't import method which is not defined...
...with Ruby code: Enumerable#drop
e
nd
e
nd
//}...

Refinement (14008.0)

refine のブロックの中の self のクラスです。

...refine のブロックの中の self のクラスです。

Refinement#import_methodsで他のモジュールからメソッドを
インポートできます。...