るりまサーチ (Ruby 2.4.0)

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

別のキーワード

  1. _builtin <
  2. bigdecimal <
  3. float <
  4. module <
  5. complex <

検索結果

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

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

...list[例][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#<=>(other) -> Integer | nil (18325.0)

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

...がクラスやモジュールでなければ
nil を返します。

@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 # =>...

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

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

...クラス

@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.ancest...

Module#ancestors -> [Class, Module] (25.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#class_variables(inherit = true) -> [Symbol] (25.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...d
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}

@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants...

絞り込み条件を変える

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

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

...ます。

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

@raise ArgumentError 継承関係が循環してしまうような include を行った場合に発生します。

//emlist[例][ruby]{
module
M
end
module
M2
include M
end
module
M
include M2
end
//}...
...ールのほうが
先に行われます
(上の例の Module#ancestors の結果がメソッド探索の順序です)。

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

//emlist[例][ruby]{
module
M
end
class C1
include M
end
class C2 < C1
include...

Module#include?(mod) -> bool (25.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#instance_methods(inherited_too = true) -> [Symbol] (25.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

そのモジュールで定義されている public および protected メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#methods

//emlist[例1][ruby]{
class Foo
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end

# あるクラスのインスタンス...

Module#method_defined?(name) -> bool (25.0)

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

...
true を返します。

@param name Symbol か String を指定します。

@see Module#public_method_defined?, Module#private_method_defined?, Module#protected_method_defined?

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

Module#private_method_defined?(name) -> bool (25.0)

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

...れば false を返します。

@param name Symbol か String を指定します。

@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...

絞り込み条件を変える

Module#protected_method_defined?(name) -> bool (25.0)

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

...ければ false を返します。

@param name Symbol か String を指定します。

@see Module#method_defined?, Module#public_method_defined?, Module#private_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
inclu...

Module#public_method_defined?(name) -> bool (25.0)

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

...れば false を返します。

@param name Symbol か String を指定します。

@see Module#method_defined?, Module#private_method_defined?, Module#protected_method_defined?

//emlist[例][ruby]{
module
A
def method1() end
end
class B
protected
def method2() end
end
class C < B
inclu...

Module#undef_method(*name) -> self (25.0)

このモジュールのインスタンスメソッド name を未定義にします。

...ng または Symbol で与えられることです。

//emlist[例][ruby]{
module
M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module
M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.insta...