別のキーワード
ライブラリ
- ビルトイン (371)
キーワード
- < (12)
- <= (12)
- <=> (12)
- > (12)
- >= (12)
-
alias
_ method (8) -
append
_ features (12) - autoload (12)
-
class
_ eval (24) -
class
_ exec (12) -
const
_ added (3) -
deprecate
_ constant (12) -
extend
_ object (12) - extended (12)
- freeze (12)
-
instance
_ method (12) -
module
_ eval (24) -
module
_ exec (12) -
prepend
_ features (12) -
private
_ class _ method (24) -
private
_ constant (12) - public (12)
-
public
_ class _ method (24) -
public
_ constant (12) -
public
_ instance _ method (12) -
remove
_ method (12) -
singleton
_ class? (12) -
undef
_ method (12)
検索結果
先頭5件
-
Module
# autoload(const _ name , feature) -> nil (6108.0) -
定数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
...数 const_name を最初に参照した時に feature を Kernel.#require するように設定します。
const_name が autoload 設定されていて、まだ定義されてない(ロードされていない)ときは、
autoload する対象を置き換えます。
const_name が(autoloadで......m const_name String または Symbol で指定します。
なお、const_name には、"::" 演算子を含めることはできません。
つまり、self の直下に定義された定数しか指定できません。
@param feature Kernel.#require と同様な方法で autoload......ist[例][ruby]{
# ------- /tmp/foo.rb ---------
class Foo
class Bar
end
end
# ----- end of /tmp/foo.rb ----
class Foo
autoload :Bar, '/tmp/foo'
end
p Foo::Bar #=> Foo::Bar
//}
以下のようにモジュールを明示的にレシーバとして呼び出すこともできます。
//emlist[... -
Module
# const _ added(name) -> () (6108.0) -
定数 name が追加された時にインタプリタがこのメソッドを呼び出します。
...定数 name が追加された時にインタプリタがこのメソッドを呼び出します。
//emlist[][ruby]{
module Chatty
def self.const_added(const_name)
super
puts "Added #{const_name.inspect}"
end
FOO = 1
end
# => Added :FOO
//}... -
Module
# <=(other) -> bool | nil (150.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
# <=>(other) -> Integer | nil (136.0) -
self と other の継承関係を比較します。
...
self と other の継承関係を比較します。
self と other を比較して、
self が other の子孫であるとき -1、
同一のクラス/モジュールのとき 0、
self が other の先祖であるとき 1
を返します。
継承関係にないクラス同士の比較では
n......il を返します。
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 <=> Baz # => nil
p Baz <=> Object.new # => nil
//}... -
Module
# <(other) -> bool | nil (134.0) -
比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。
...比較演算子。self が other の子孫である場合、 true を返します。
self が other の先祖か同一のクラス/モジュールである場合、false を返します。
継承関係にないクラス同士の比較では
nil を返します。
@param other 比較対象のモ......やクラス
@raise 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
# >(other) -> bool | nil (134.0) -
比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。
...。 self が other の先祖である場合、true を返します。
self が other の子孫か同一クラスである場合、false を返します。
継承関係にないクラス同士の比較では
nil を返します。
@param other 比較対象のモジュールやクラス
@raise Type......Error other がクラスやモジュールではない場合に発生します。
@see Module#<
//emlist[例][ruby]{
module Awesome; end
module Included
include Awesome
end
module Prepended
prepend Awesome
end
Included.ancestors # => [Included, Awesome]
Awesome > Included # => true
Included >......Awesome # => false
Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepended # => true
Prepended > Awesome # => false
Awesome > Awesome # => false
Awesome > Object # => nil
//}... -
Module
# >=(other) -> bool | nil (134.0) -
比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。
...。self が other の先祖か同一クラスである場合、 true を返します。
self が other の子孫である場合、false を返します。
継承関係にないクラス同士の比較では
nil を返します。
@param other 比較対象のモジュールやクラス
@raise Type......Error 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.ancestors # => [Foo, Baz]
Fo......o >= Baz # => true
Baz >= Foo # => false
Foo >= Foo # => true
Foo >= Object # => nil
//}... -
Module
# class _ exec(*args) {|*vars| . . . } -> object (126.0) -
与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。
...ュールのコンテキストで評価します。
モジュールのコンテキストで評価するとは、実行中そのモジュールが self になるということです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。
ローカル変......す。
//emlist[例][ruby]{
class Thing
end
c = 1
Thing.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 _ exec(*args) {|*vars| . . . } -> object (126.0) -
与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。
...ュールのコンテキストで評価します。
モジュールのコンテキストで評価するとは、実行中そのモジュールが self になるということです。
つまり、そのモジュールの定義式の中にあるかのように実行されます。
ローカル変......す。
//emlist[例][ruby]{
class Thing
end
c = 1
Thing.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
# public(name) -> String | Symbol (114.0) -
メソッドを public に設定します。
...f#limit を参照して下さい。
@param name 0 個以上の String または Symbol を指定します。
@param names 0 個以上の String または Symbol を Array で指定します。
@raise NameError 存在しないメソッド名を指定した場合に発生します。
//emlist[例]......def foo() 1 end
p foo # => 1
# the toplevel default is private
p self.foo # => private method `foo' called for #<Object:0x401c83b0> (NoMethodError)
def bar() 2 end
public :bar # visibility changed (all access allowed)
p bar # => 2
p self.bar # => 2
//}...