402件ヒット
[201-300件を表示]
(0.249秒)
種類
- インスタンスメソッド (391)
- 特異メソッド (11)
キーワード
- <=> (11)
-
_ dump (11) - display (11)
-
enum
_ for (22) - extend (11)
- initialize (11)
-
initialize
_ copy (11) - inspect (11)
-
instance
_ of? (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
is
_ a? (11) -
kind
_ of? (11) -
marshal
_ dump (11) - methods (11)
-
remove
_ instance _ variable (11) -
respond
_ to? (11) -
respond
_ to _ missing? (11) - send (22)
-
singleton
_ class (11) -
singleton
_ method (11) -
singleton
_ methods (11) - tainted? (6)
-
to
_ ary (11) -
to
_ enum (22) -
to
_ hash (11) -
to
_ int (11) -
to
_ proc (11) -
to
_ regexp (11) -
to
_ s (11) -
to
_ str (11)
検索結果
先頭5件
-
Object
# instance _ variable _ defined?(var) -> bool (8009.0) -
インスタンス変数 var が定義されていたら真を返します。
..., @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
# instance _ variable _ get(var) -> object | nil (8009.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...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?... -
Object
# instance _ variable _ set(var , value) -> object (8009.0) -
オブジェクトのインスタンス変数 var に値 value を設定します。
...value を返します。
//emlist[][ruby]{
obj = Object.new
p obj.instance_variable_set("@foo", 1) #=> 1
p obj.instance_variable_set(:@foo, 2) #=> 2
p obj.instance_variable_get(:@foo) #=> 2
//}
@see Object#instance_variable_get,Object#instance_variables,Object#instance_variable_defined?... -
Object
# instance _ variables -> [Symbol] (8009.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...スタンス変数名をシンボルの配列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, M... -
Object
# is _ a?(mod) -> bool (8009.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に fa......です。
//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 (8009.0) -
オブジェクトが指定されたクラス mod かそのサブクラスのインスタンスであるとき真を返します。
...ードしたクラスかそのサブクラス
のインスタンスである場合にも真を返します。
Module#includeだけではなく、Object#extendやModule#prependに
よってサブクラスのインスタンスになる場合も含みます。
上記のいずれでもない場合に fa......です。
//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
# marshal _ dump -> object (8009.0) -
Marshal.#dump を制御するメソッドです。
...oo
def initialize(arg)
@foo = arg
end
def marshal_dump
@foo
end
def marshal_load(obj)
p obj
@foo = obj
end
end
foo = Foo.new(['foo', 'bar'])
p foo #=> #<Foo:0xbaf3b0 @foo=["foo", "bar"]>
dms = Marshal.dump(foo)
p dms #=> "\004\bU:......定義されていてもマーシャルできるようになります
(特異メソッドの情報が自動的に dump されるようになるわけではなく、
marshal_dump/marshal_load によりそれを実現する余地があるということです)。
@see Object#marshal_load, Marshal... -
Object
# methods(include _ inherited = true) -> [Symbol] (8009.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...ected メソッドの名前を返します。
ただし特別に、引数が偽の時は Object#singleton_methods(false) と同じになっています。
@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。
//emlist[例1][ruby]{
class Parent......nd
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 protected_singleton() end
public; def public_singleton() end......指定して
# いるが、Object のインスタンスメソッドは一覧から排除している。
p obj.methods(true) - Object.instance_methods(true)
p obj.public_methods(true) - Object.public_instance_methods(true)
p obj.private_methods(true) - Object.private_instance_methods(t... -
Object
# remove _ instance _ variable(name) -> object (8009.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...ない場合に発生します。
//emlist[][ruby]{
class Foo
def foo
@foo = 1
p remove_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
# respond _ to _ missing?(symbol , include _ private) -> bool (8009.0) -
自身が symbol で表されるメソッドに対し BasicObject#method_missing で反応するつもりならば真を返します。
...れるメソッドに対し
BasicObject#method_missing で反応するつもりならば真を返します。
Object#respond_to? はメソッドが定義されていない場合、
デフォルトでこのメソッドを呼びだし問合せます。
BasicObject#method_missing を override した......end
end
def respond_to_missing?(sym, include_private)
(sym =~ /^to_*/) ? true : super
end
end
s = Sample.new
s.to_sample("sample args1", "sample args2")
s.respond_to?(:to_sample) # => true
s.respond_to?(:sample) # => false
//}
@see Object#respond_to?, BasicObject#method_missing...