るりまサーチ

最速Rubyリファレンスマニュアル検索!
60件ヒット [1-60件を表示] (0.076秒)

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. class new
  5. argf.class readline

ライブラリ

クラス

キーワード

検索結果

Module#included(class_or_module) -> () (18221.0)

self が Module#include されたときに対象のクラスまたはモジュー ルを引数にしてインタプリタがこのメソッドを呼び出します。

...タプリタがこのメソッドを呼び出します。

@param class_or_module Module#include を実行したオブジェクト

//emlist[例][ruby]{
module Foo
def self.included(mod)
p "#{mod} include #{self}"
end
end
class
Bar
include Foo
end
# => "Bar include Foo"
//}

@see Module#ap...

Module#ancestors -> [Class, Module] (126.0)

クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。

...先順位順に配列に格納して返します。

//emlist[例][ruby]{
module Foo
end
class
Bar
include Foo
end
class
Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}

@see Module#included_modules...

Module#append_features(module_or_class) -> self (120.0)

モジュール(あるいはクラス)に self の機能を追加します。

...ude(*modules)
modules.reverse_each do |mod|
# append_features や included はプライベートメソッドなので
# 直接 mod.append_features(self) などとは書けない
mod.__send__(:append_features, self)
mod.__send__(:included, self)
end
end
//}

@see Module#included...

Module#prepended(class_or_module) -> () (114.0)

self が Module#prepend されたときに対象のクラスまたはモジュールを 引数にしてインタプリタがこのメソッドを呼び出します。

...ます。

@param class_or_module Module#prepend を実行したオブジェクト

//emlist[例][ruby]{
module A
def self.prepended(mod)
puts "#{self} prepended to #{mod}"
end
end
module Enumerable
prepend A
end
# => "A prepended to Enumerable"
//}

@see Module#included, Module#prepend, M...

Object#extend(*modules) -> self (19.0)

引数で指定したモジュールのインスタンスメソッドを self の特異 メソッドとして追加します。

...a
'ok Foo'
end
end

module Bar
def b
'ok Bar'
end
end

obj = Object.new
obj.extend Foo, Bar
p obj.a #=> "ok Foo"
p obj.b #=> "ok Bar"

class
Klass
include Foo
extend Bar
end

p Klass.new.a #=> "ok Foo"
p Klass.b #=> "ok Bar"
//}

extend の機能は、「特異クラスに対...
...ただしその場合、フック用のメソッド
が Module#extended ではなく Module#included になるという違いがあります。

//emlist[][ruby]{
# obj.extend Foo, Bar とほぼ同じ
class
<< obj
include Foo, Bar
end
//}

@see Module#extend_object,Module#include,Module#extended...

絞り込み条件を変える