るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. rexml end_document

検索結果

<< 1 2 > >>

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

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

...す。

@
param mod Module のインスタンス( Enumerable など)を指定します。

@
raise ArgumentError 継承関係が循環してしまうような 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]
//}

モジュールの機能追加は、クラスの継承関係の間にそのモジュールが挿入
されるこ...

Module#<(other) -> bool | nil (18180.0)

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

...す。

@
param other 比較対象のモジュールやクラス

@
raise TypeError other がクラスやモジュールではない場合に発生します。

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

class Bar
include
Foo
end

class Baz < Bar
end

class Qux
end

p Bar < Foo # => true
p Baz < Bar #...
...=> true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}...

Module#include?(mod) -> bool (6151.0)

self かその親クラス / 親モジュールがモジュール mod を インクルードしていれば true を返します。

...クラス / 親モジュールがモジュール mod を
インクルードしていれば true を返します。

@
param mod Module を指定します。

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

class C1
include
M
end

class C2 < C1
end


p C1.include?(M) # => true
p C2.include?(M) # => true
//}...

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

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

...

@
param other 比較対象のモジュールやクラス

@
raise TypeError other がクラスやモジュールではない場合に発生します。

@
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 <= Foo # => true
Foo <= Object # => nil
//}...

Module#<=>(other) -> Integer | nil (6144.0)

self と other の継承関係を比較します。

...

@
param other 比較対象のクラスやモジュール

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

class Bar
include
Foo
end

class Baz < Bar
end

class Qux
end

p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=>...

絞り込み条件を変える

Module#method_defined?(name, inherit=true) -> bool (86.0)

モジュールにインスタンスメソッド name が定義されており、 かつその可視性が public または protected であるときに true を返します。

...す。

@
param name Symbol か String を指定します。
@
param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@
see Module#public_method_defined?, Module#private_method_defined?, Module#protecte...
...od_defined?

//emlist[例][ruby]{
module
A
def method1() end
def protected_method1() end
protected :protected_method1
end

class B
def method2() end
def private_method2() end
private :private_method2
end

class C < B
include
A
def method3() end
end


A.method_defined? :method1...

Module#private_method_defined?(name, inherit=true) -> bool (74.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が private であるときに true を返します。 そうでなければ false を返します。

...します。

@
param name Symbol か String を指定します。
@
param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@
see Module#method_defined?, Module#public_method_defined?, Module#protected_...
...method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
private
def method2() end
end

class C < B
include
A
def method3() end
end


A.method_defined? :method1 #=> true
C.private_method_defined? "method1" #=> false
C.private_method_defined?...

Module#protected_method_defined?(name, inherit=true) -> bool (74.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が protected であるときに true を返します。 そうでなければ false を返します。

...します。

@
param name Symbol か String を指定します。
@
param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@
see Module#method_defined?, Module#public_method_defined?, Module#private_me...
...thod_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
protected
def method2() end
end

class C < B
include
A
def method3() end
end


A.method_defined? :method1 #=> true
C.protected_method_defined? "method1" #=> false
C.protected_method_defin...

Module#public_method_defined?(name, inherit=true) -> bool (74.0)

インスタンスメソッド name がモジュールに定義されており、 しかもその可視性が public であるときに true を返します。 そうでなければ false を返します。

...ます。

@
param name Symbol か String を指定します。
@
param inherit 真を指定するとスーパークラスや include したモジュールで
定義されたメソッドも対象になります。

@
see Module#method_defined?, Module#private_method_defined?, Module#protected_me...
...thod_defined?

//emlist[例][ruby]{
module
A
def method1() end
end

class B
protected
def method2() end
end

class C < B
include
A
def method3() end
end


A.method_defined? :method1 #=> true
C.public_method_defined? "method1" #=> true
C.public_method_defined? "metho...
<< 1 2 > >>