るりまサーチ

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

別のキーワード

  1. kernel system
  2. kernel spawn
  3. kernel exec
  4. kernel open
  5. kernel caller

ライブラリ

クラス

検索結果

Module#ancestors -> [Class, Module] (18233.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#include(*mod) -> self (49.0)

モジュール mod をインクルードします。

...重継承の代わりに用いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class
C
include FileTest
include Math
end

p C.ancestors

# => [C, Math, FileTest, Object, Kernel]
//}

モジュールの機能追加は、クラスの継承関係の間にそのモジュール...
...#ancestors の結果がメソッド探索の順序です)。

同じモジュールを二回以上 include すると二回目以降は無視されます。

//emlist[例][ruby]{
module M
end
class
C1
include M
end
class
C2 < C1
include M # この include は無視される
end

p C2.ancestors...
...# => [C2, C1, M, Object, Kernel]
//}

引数に複数のモジュールを指定した場合、
最後の引数から順にインクルードします。...