るりまサーチ

最速Rubyリファレンスマニュアル検索!
105件ヒット [1-100件を表示] (0.220秒)
トップページ > クエリ:-[x] > クエリ:r[x] > クエリ:t[x] > クエリ:<[x] > クラス:Module[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

検索結果

<< 1 2 > >>

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

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

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

継承関係にないクラス同士の比較では
nil を返します。

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

@r...
...aise 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#protected_method_defined?(name) -> bool (18407.0)

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

...性が protected であるときに true を返します。
そうでなければ false を返します。

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

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

//emlist[例][ruby]{
module
A
def method1()...
...nd
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.method_defined? "method2"...
...#=> true
//}...

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

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

...ュールに定義されており、
しかもその可視性が protected であるときに true を返します。
そうでなければ false を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジ...
...e 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.prot...
...ected_method_defined? "method1" #=> false
C.protected_method_defined? "method2" #=> true
C.protected_method_defined? "method2", true #=> true
C.protected_method_defined? "method2", false #=> false
C.method_defined? "method2" #=> true
//}...

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

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

...ュールに定義されており、
しかもその可視性が private であるときに true を返します。
そうでなければ false を返します。

@param name Symbol か String を指定します。
@param inherit 真を指定するとスーパークラスや include したモジュ...
... 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.privat...
...e_method_defined? "method1" #=> false
C.private_method_defined? "method2" #=> true
C.private_method_defined? "method2", true #=> true
C.private_method_defined? "method2", false #=> false
C.method_defined? "method2" #=> false
//}...

Module#ancestors -> [Class, Module] (12307.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...
...先順位順に配列に格納して返します。

//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#const_source_location(name, inherited = true) -> [String, Integer] (12307.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...す。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@return ソース...
...st[例][ruby]{
# test.rb:
class A # line 1
C1 = 1
C2 = 2
end

module
M # line 6
C3 = 3
end

class B < A # line 10
include M
C4 = 4
end

class A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end

p B.const_source_location('C4') # => ["test...
....rb", 12]
p B.const_source_location('C3') # => ["test.rb", 7]
p B.const_source_location('C1') # => ["test.rb", 2]

p B.const_source_location('C3', false) # => nil -- include したモジュールは検索しない

p A.const_source_location('C2') # => ["test.rb", 16...

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

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

...性が private であるときに true を返します。
そうでなければ false を返します。

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

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

//emlist[例][ruby]{
module
A
def method1()...
...d
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.method_defined? "method2"...

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

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

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

self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。

継承関係にないクラス同士の比較では
n...
...

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 <=> Fo...
...o # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

Module#class_variables(inherit = true) -> [Symbol] (6407.0)

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

...aram inherit false を指定しない場合はスーパークラスやインクルードして
いるモジュールのクラス変数を含みます。

//emlist[例][ruby]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
T
wo.class_vari...
...ables # => [:@@var2, :@@var1]
T
wo.class_variables(false) # => [:@@var2]
//}

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

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

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

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

継承関係にないクラス同士の比較では
nil を返します。

@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#instance_methods(inherited_too = true) -> [Symbol] (6331.0)

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

...protected メソッド名
の一覧を配列で返します。

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

@see Object#methods

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

# あるクラスのインスタンスメソッドの一覧を得る
p Foo.instance_methods(false)
p Foo.public_instance_methods(false)
p Foo.private_instance_methods(false)
p Foo.protected_instance_methods(false)

class Bar < Foo
end
//}...
...実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]

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

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

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

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

...たは protected であるときに
t
rue を返します。

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

@see Module#public_method_defi...
...#private_method_defined?, Module#protected_method_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 meth...
...method_defined? :method1 #=> true
C.method_defined? "method1" #=> true
C.method_defined? "method2" #=> true
C.method_defined? "method2", true #=> true
C.method_defined? "method2", false #=> false
C.method_defined? "method3" #=> true
C.metho...

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

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

... true を返します。
そうでなければ false を返します。

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

@see Module#method...
..., 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
include A
def method3() end
end

A.method_defined? :method1 #=> true
C.public_method_defined? "meth...
...od1" #=> true
C.public_method_defined? "method1", true #=> true
C.public_method_defined? "method1", false #=> true
C.public_method_defined? "method2" #=> false
C.method_defined? "method2" #=> true
//}...
<< 1 2 > >>