るりまサーチ

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.235秒)
トップページ > クエリ:I[x] > クエリ:RUBY[x] > クエリ:E[x] > クエリ:import_methods[x]

別のキーワード

  1. open3 popen2e
  2. socket af_e164
  3. open3 capture2e
  4. matrix det_e
  5. matrix rank_e

ライブラリ

クラス

検索結果

Refinement#import_methods(*modules) -> self (30337.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
//}...