65件ヒット
[1-65件を表示]
(0.079秒)
別のキーワード
種類
- インスタンスメソッド (43)
- 特異メソッド (22)
キーワード
- ancestors (11)
- class (11)
- new (22)
-
super
_ method (10)
検索結果
先頭5件
-
Class
# superclass -> Class | nil (24239.0) -
自身のスーパークラスを返します。
...y]{
File.superclass #=> IO
IO.superclass #=> Object
class Foo; end
class Bar < Foo; end
Bar.superclass #=> Foo
Object.superclass #=> BasicObject
//}
ただし BasicObject.superclass は nil を返します。
//emlist[例][ruby]{
BasicObject.superclass #=> ni... -
Method
# super _ method -> Method | nil (6114.0) -
self 内で super を実行した際に実行されるメソッドを Method オブジェ クトにして返します。
...self 内で super を実行した際に実行されるメソッドを Method オブジェ
クトにして返します。
@see UnboundMethod#super_method
//emlist[例][ruby]{
class Super
def foo
"superclass method"
end
end
class Sub < Super
def foo
"subclass method"
end
end
m = S......ub.new.method(:foo) # => #<Method: Sub#foo>
m.call # => "subclass method"
m.super_method # => #<Method: Super#foo>
m.super_method.call # => "superclass method"
//}... -
Class
. new(superclass = Object) -> Class (268.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...ない superclass のサブクラスを生成します。
名前のないクラスは、最初に名前を求める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name......# => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name # => "Bar" ("Foo" になるか "Bar" になるかは不定)
//}
ブロックが与えられた場合、生成したクラスを引数として
クラスのコンテキストでブロック......じです。
//emlist[例][ruby]{
klass = Class.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定... -
Class
. new(superclass = Object) {|klass| . . . } -> Class (268.0) -
新しく名前の付いていない superclass のサブクラスを生成します。
...ない superclass のサブクラスを生成します。
名前のないクラスは、最初に名前を求める際に代入されている定数名を検
索し、見つかった定数名をクラス名とします。
//emlist[例][ruby]{
p foo = Class.new # => #<Class:0x401b90f8>
p foo.name......# => nil
Foo = foo # ここで p foo すれば "Foo" 固定
Bar = foo
p foo.name # => "Bar" ("Foo" になるか "Bar" になるかは不定)
//}
ブロックが与えられた場合、生成したクラスを引数として
クラスのコンテキストでブロック......じです。
//emlist[例][ruby]{
klass = Class.new(superclass)
klass.module_eval {|m|
# ...
}
klass
//}
この場合も生成したクラスを返します。
ブロックの実行は Class#initialize が行います。
@param superclass 生成するクラスのスーパークラスを指定... -
Object
# class -> Class (44.0) -
レシーバのクラスを返します。
...レシーバのクラスを返します。
//emlist[][ruby]{
p "ruby".class #=> String
p 100.class #=> Integer
p ARGV.class #=> Array
p self.class #=> Object
p Class.class #=> Class
p Kernel.class #=> Module
//}
@see Class#superclass,Object#kind_of?,Object#instance_of?... -
Module
# ancestors -> [Class , Module] (26.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...