るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle build_ruby_platform
  3. fiddle ruby_free
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

Module#include(*mod) -> self (18264.0)

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

...てしまうような include を行った場合に発生します。

//emlist[例][ruby]{
module M
end

module M2
include
M
end

module M
include
M2
end

//}

実行結果:

-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3...
...インクルードは多重継承の代わりに用いられており、 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...

Module#ancestors -> [Class, Module] (18144.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#included_modules -> [Module] (6137.0)

self にインクルードされているモジュールの配列を返します。

...self にインクルードされているモジュールの配列を返します。

//emlist[例][ruby]{
module Mixin
end


module Outer
include
Mixin
end


Mixin.included_modules #=> []
Outer.included_modules #=> [Mixin]
//}

@see Module#ancestors...

Module#<=(other) -> bool | nil (49.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...ない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include
Foo
end

module Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

Baz.ancestors # => [Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true

Foo <=...

Module#>(other) -> bool | nil (49.0)

比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。

...][ruby]{
module Awesome; end
module Included
include
Awesome
end

module Prepended
prepend Awesome
end


Include
d.ancestors # => [Included, Awesome]
Awesome > Included # => true
Include
d > Awesome # => false

Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepended # => true
Prepended > A...

絞り込み条件を変える

Module#>=(other) -> bool | nil (49.0)

比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。

...ない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include
Foo
end

module Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false

Baz.ancestors # => [Foo, Baz]
Foo >= Baz # => true
Baz >= Foo # => false

Foo >=...