るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

キーワード

検索結果

<< 1 2 3 > >>

Module#class_eval {|mod| ... } -> object (8106.0)

モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ことです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。

文字列が与えられた場合には、定数とクラス変数のスコープ...
...などを差し替えることができます。

//emlist[例][ruby]{
class C
end
a = 1
C.class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end
}

p C.new.m #=> [:m, 1]
//}

@see BasicObject#instance_eval, Module.new, Kernel.#eval...

Module#class_exec(*args) {|*vars| ... } -> object (8106.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...ing.class_exec{
def hello()
"Hello there!"
end

define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t = Thing.new
p t.hello() #=> "Hello there!"
p t.foo() #=> 1
//}

@see Module#module_eval, Module#class_eval...

Module#module_eval {|mod| ... } -> object (8106.0)

モジュールのコンテキストで文字列 expr またはモジュール自身をブロックパラメータとするブロックを 評価してその結果を返します。

...ことです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。

ただし、ローカル変数は module_eval/class_eval の外側のスコープと共有します。

文字列が与えられた場合には、定数とクラス変数のスコープ...
...などを差し替えることができます。

//emlist[例][ruby]{
class C
end
a = 1
C.class_eval %Q{
def m # メソッドを動的に定義できる。
return :m, #{a}
end
}

p C.new.m #=> [:m, 1]
//}

@see BasicObject#instance_eval, Module.new, Kernel.#eval...

Module#module_exec(*args) {|*vars| ... } -> object (8106.0)

与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。

...ing.class_exec{
def hello()
"Hello there!"
end

define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}

t = Thing.new
p t.hello() #=> "Hello there!"
p t.foo() #=> 1
//}

@see Module#module_eval, Module#class_eval...

Module#<(other) -> bool | nil (8105.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) -> bool | nil (8105.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#<=>(other) -> Integer | nil (8105.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 (8105.0)

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

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

@see Module#<

//emlist[例][ruby]{
module
Awesome; end
module
Included
include Awesome
end
module
Prepended
prepend Awesome
end

Included.ancestors # => [Included, Awesome]
Awesome > Included # => tr...

Module#>=(other) -> bool | nil (8105.0)

比較演算子。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 # => true
Bar >= Foo # => false

Baz.ancest...

Module#autoload?(const_name) -> String | nil (8105.0)

autoload 定数がまだ定義されてない(ロードされていない) ときにそのパス名を返します。 また、ロード済みなら nil を返します。

autoload 定数がまだ定義されてない(ロードされていない) ときにそのパス名を返します。
また、ロード済みなら nil を返します。

@param const_name String または Symbol で指定します。

@see Kernel.#autoload?

//emlist[例][ruby]{
autoload :Date, 'date'

autoload?(:Date) # => "date"
Date
autoload?(:Date) # => nil
autoload?(:Foo) # => nil
//}

絞り込み条件を変える

<< 1 2 3 > >>