408件ヒット
[201-300件を表示]
(0.061秒)
別のキーワード
キーワード
- === (12)
-
_ dump (12) -
define
_ singleton _ method (24) - display (12)
- extend (12)
- initialize (12)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ of? (12) -
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
instance
_ variables (12) -
is
_ a? (12) -
kind
_ of? (12) -
marshal
_ dump (12) -
marshal
_ load (12) - methods (12)
-
pretty
_ print (12) -
pretty
_ print _ cycle (12) -
public
_ method (12) -
remove
_ instance _ variable (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ class (12) -
singleton
_ method (12) -
singleton
_ methods (12) -
to
_ ary (12) -
to
_ int (12) -
to
_ s (12) -
to
_ str (12)
検索結果
先頭5件
-
Object
# methods(include _ inherited = true) -> [Symbol] (56.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...。
ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent
private; def private_parent() end......; def protected_parent() end
public; def public_parent() end
end
class Foo < Parent
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
obj = Foo.new
class <<obj
private; def private_singleton() end
protected; def p......ton, :protected_foo]
//}
//emlist[例2][ruby]{
# あるオブジェクトの応答できるメソッドの一覧を得る。
# 自身のクラスの親クラスのインスタンスメソッドも含めるために true を指定して
# いるが、Object のインスタンスメソッドは一... -
Object
# remove _ instance _ variable(name) -> object (56.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...を返します。
@param name 削除するインスタンス変数の名前をシンボルか文字列で指定します。
@raise NameError オブジェクトがインスタンス変数 name を持たない場合に発生します。
//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remov......e_instance_variable(:@foo) #=> 1
p remove_instance_variable(:@foo) # instance variable @foo not defined (NameError)
end
end
Foo.new.foo
//}
@see Module#remove_class_variable,Module#remove_const... -
Object
# display(out = $ stdout) -> nil (50.0) -
オブジェクトを out に出力します。
...mlist[][ruby]{
class Object
def display(out = $stdout)
out.write self
nil
end
end
//}
@param out 出力先のIOオブジェクトです。指定しない場合は標準出力に出力されます。
@return nil を返します。
//emlist[][ruby]{
Object.new.display #=> #<Object:0xbb02... -
Object
# instance _ of?(klass) -> bool (50.0) -
オブジェクトがクラス klass の直接のインスタンスである時真を返します。
...常に obj.kind_of?(c) も成立します。
@param klass Classかそのサブクラスのインスタンスです。
//emlist[][ruby]{
class C < Object
end
class S < C
end
obj = S.new
p obj.instance_of?(S) # true
p obj.instance_of?(C) # false
//}
@see Object#kind_of?,Object#class... -
Object
# to _ s -> String (50.0) -
オブジェクトの文字列表現を返します。
...使って文字列に変換し
ます。
//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it = Foo.new(40)
puts it #=> #<Foo:0x2b69110>
class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end
puts it #=> Class:Foo Number:40
//}
@see Object#to_str,Kernel.#String... -
Object
# instance _ variable _ defined?(var) -> bool (44.0) -
インスタンス変数 var が定義されていたら真を返します。
...す。
@param var インスタンス変数名を文字列か Symbol で指定します。
//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=>......true
p fred.instance_variable_defined?("@c") #=> false
//}
@see Object#instance_variable_get,Object#instance_variable_set,Object#instance_variables... -
Object
# is _ a?(mod) -> bool (44.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...も真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返します。
@param mod クラスやモジュールなど、Moduleかそ......です。
//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end
obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}
@see Object#instance_of?,Module#===,Object#class... -
Object
# kind _ of?(mod) -> bool (44.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...も真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に false を返します。
@param mod クラスやモジュールなど、Moduleかそ......です。
//emlist[][ruby]{
module M
end
class C < Object
include M
end
class S < C
end
obj = S.new
p obj.is_a?(S) # true
p obj.is_a?(C) # true
p obj.is_a?(Object) # true
p obj.is_a?(M) # true
p obj.is_a?(Hash) # false
//}
@see Object#instance_of?,Module#===,Object#class... -
Object
# instance _ variable _ get(var) -> object | nil (38.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...。
@param var インスタンス変数名を文字列か Symbol で指定します。
//emlist[][ruby]{
class Foo
def initialize
@foo = 1
end
end
obj = Foo.new
p obj.instance_variable_get("@foo") #=> 1
p obj.instance_variable_get(:@foo) #=> 1
p obj.instance_variable_get(:@bar)......#=> nil
//}
@see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?...