16件ヒット
[1-16件を表示]
(0.057秒)
別のキーワード
ライブラリ
- ビルトイン (16)
クラス
- Module (12)
- Refinement (4)
検索結果
-
Module
# using(module) -> self (18221.0) -
引数で指定したモジュールで定義された拡張を現在のクラス、モジュールで有 効にします。
...ルで有
効にします。
有効にした拡張の有効範囲については以下を参照してください。
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html#label-Scope
@param module 有効にするモジュールを指定します。
@see Module#refine, main.using... -
Refinement
# import _ methods(*modules) -> self (150.0) -
モジュールからメソッドをインポートします。
...ため、Rubyコードで定義されたメソッドだけしか
インポートできないことに注意してください。
//emlist[][ruby]{
module StrUtils
def indent(level)
' ' * level + self
end
end
module M
refine String do
import_methods StrUtils
end
end
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
end
end
//}...