るりまサーチ

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

別のキーワード

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

検索結果

<< < 1 2 3 4 5 > >>

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

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

...t[例][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#constants(inherit = true) -> [Symbol] (31.0)

そのモジュール(またはクラス)で定義されている定数名の配列を返します。

...パークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。

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

//eml...
...し引く
$clist = Module.constants

class
Foo
FOO = 1
end
class
Bar
BAR = 1

# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class
Baz
# Baz は定数を含まな...

Module#prepend_features(mod) -> self (31.0)

Module#prepend から呼び出されるメソッドで、 prepend の処理の実体です。このメソッド自体は mod で指定した モジュール/クラスの継承チェインの先頭に self を追加します。

...ュール
@return mod が返されます

//emlist[例][ruby]{
class
Recorder
RECORDS = []
end

module X
def self.prepend_features(mod)
Recorder::RECORDS << mod
end
end

class
A
prepend X
end

class
B
include
X
end

class
C
prepend X
end

Recorder::RECORDS # => [A, C]
//}

@see Modul...

Object#is_a?(mod) -> bool (31.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...ュール mod をインクルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のい...
...です。

//emlist[][ruby]{
module M
end
class
C < Object
include
M
end
class
S < C
end

obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

Object#kind_of?(mod) -> bool (31.0)

オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。

...ュール mod をインクルードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のい...
...です。

//emlist[][ruby]{
module M
end
class
C < Object
include
M
end
class
S < C
end

obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}

@see Object#instance_of?,Module#===,Object#class...

絞り込み条件を変える

Module#<=>(other) -> Integer | nil (25.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 # => -1
p Baz <=> Qux # => nil
p Qux <=>...

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

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

...きに
true を返します。

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

@see Module#public_method_defined?, Module#private_method_d...
...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 #=> true
C.method_defined...

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

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

... 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? "method2" #=> true
C.private_method_defined? "method2", true #=> true
C.private_method_defined? "method2", fals...

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

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

... include したモジュールで
定義されたメソッドも対象になります。

@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
include
A
def method3() end
end

A.method_defined? :method1 #=> true
C.protected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "method2"...
<< < 1 2 3 4 5 > >>