るりまサーチ

最速Rubyリファレンスマニュアル検索!
270件ヒット [201-270件を表示] (0.036秒)
トップページ > クエリ:Object#class[x] > クエリ:to_regexp[x] > クラス:Module[x] > 種類:インスタンスメソッド[x]

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. argf.class to_a
  5. argf.class gets

検索結果

<< < 1 2 3 >>

Module#const_defined?(name, inherit = true) -> bool (44.0)

モジュールに name で指定される名前の定数が定義されている時真 を返します。

...例][ruby]{
module
Kernel
FOO = 1
end

# Object は include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true

module
Bar
BAR = 1
end
class
Object
include Bar
end
# ユーザ定義のモジュールに対しても同様
p Object.const_defi...
...ned?(:BAR) # => true

class
Baz
include Bar
end
# Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true

# 第二引数を false にした場合
p Baz.const_defined?(:BAR, false) # => false
//}...

Module#<(other) -> bool | nil (32.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#include(*mod) -> self (32.0)

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

...ます。

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

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

//emlist[例][ruby]{
module
M
end
module
M2
include M
end
module
M
include M2
end
//}...
...多重継承の代わりに用いられており、 mix-in とも呼びます。

//emlist[例][ruby]{
class
C
include FileTest
include Math
end

p C.ancestors

# => [C, Math, FileTest, Object, Kernel]
//}

モジュールの機能追加は、クラスの継承関係の間にそのモジュー...
...先に行われます
(上の例の Module#ancestors の結果がメソッド探索の順序です)。

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

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

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

self と 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 <=> Object.new # => nil
//}...

Module#private_constant(*name) -> self (20.0)

name で指定した定数の可視性を private に変更します。

...数を指定した場合に発生します。

@return self を返します。

@see Module#public_constant, Object#untrusted?

//emlist[例][ruby]{
module
Foo
BAR = 'bar'
class
Baz; end
QUX = 'qux'
class
Quux; end

private_constant :QUX
private_constant :Quux
end

Foo::BAR # => "bar"
F...

絞り込み条件を変える

Module#instance_method(name) -> UnboundMethod (14.0)

self のインスタンスメソッド name をオブジェクト化した UnboundMethod を返します。

...します。

@raise NameError self に存在しないメソッドを指定した場合に発生します。

@see Module#public_instance_method, Object#method

//emlist[例][ruby]{
class
Interpreter
def do_a() print "there, "; end
def do_d() print "Hello "; end
def do_e() print "!\n"; en...

Module#public_constant(*name) -> self (14.0)

name で指定した定数の可視性を public に変更します。

...{
module
SampleModule
class
SampleInnerClass
end

# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end

begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInnerClass...
...referenced>
end

module
SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end

SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}

@see Module#private_constant, Object#untrusted?...
<< < 1 2 3 >>