318件ヒット
[1-100件を表示]
(0.072秒)
種類
- インスタンスメソッド (244)
- モジュール関数 (33)
- クラス (18)
- 変数 (14)
- 特異メソッド (9)
モジュール
- Kernel (47)
キーワード
-
$ -K (7) -
$ KCODE (7) - ConditionVariable (18)
- [] (11)
- broadcast (9)
-
class
_ variable _ defined? (11) -
class
_ variable _ get (11) -
class
_ variable _ set (11) -
class
_ variables (11) -
global
_ variables (11) -
instance
_ variable _ defined? (11) -
instance
_ variable _ get (11) -
instance
_ variable _ set (11) -
instance
_ variables (11) -
local
_ variable _ defined? (11) -
local
_ variable _ get (11) -
local
_ variable _ set (11) -
local
_ variables (30) - new (9)
-
remove
_ class _ variable (11) -
remove
_ instance _ variable (11) -
require
_ relative (11) - signal (9)
-
thread
_ variable? (11) -
thread
_ variable _ get (11) -
thread
_ variable _ set (11) -
to
_ s (11) - wait (9)
検索結果
先頭5件
-
Object
# instance _ variable _ defined?(var) -> bool (18333.0) -
インスタンス変数 var が定義されていたら真を返します。
...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_ge......t,Object#instance_variable_set,Object#instance_variables... -
Binding
# local _ variable _ defined?(symbol) -> bool (18233.0) -
引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。
...//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_defined?(:a) # => true
binding.local_variable_defined?(:b) # => false
end
//}
このメソッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("defined?(#{symbol}) == 'local-variable'")
//}
@see Binding#lo......cal_variable_get, Binding#local_variable_set... -
Binding
# local _ variable _ set(symbol , obj) (15251.0) -
引数 symbol で指定した名前のローカル変数に引数 obj を設定します。
...//emlist[例][ruby]{
def foo
a = 1
bind = binding
bind.local_variable_set(:a, 2) # set existing local variable `a'
bind.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.lo......cal_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}
このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。
//emlist[][ruby]{
binding.eval("#{sy......mbol} = #{obj}")
//}
@see Binding#local_variable_get, Binding#local_variable_defined?... -
Binding
# local _ variable _ get(symbol) -> object (15227.0) -
引数 symbol で指定した名前のローカル変数に設定された値を返します。
...ol オブジェクトで指定します。
@raise NameError 引数 symbol で指定したローカル変数が未定義の場合に発生します。
//emlist[例][ruby]{
def foo
a = 1
binding.local_variable_get(:a) # => 1
binding.local_variable_get(:b) # => NameError
end
//}
このメソ......ッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("#{symbol}")
//}
@see Binding#local_variable_set, Binding#local_variable_defined?... -
Binding
# local _ variables -> [Symbol] (15202.0) -
ローカル変数の一覧を Symbol の配列で返します。
...カル変数の一覧を Symbol の配列で返します。
//emlist[例][ruby]{
def foo
a = 1
2.times do |n|
binding.local_variables #=> [:a, :n]
end
end
//}
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("local_variables")
//}... -
Object
# instance _ variable _ get(var) -> object | nil (12233.0) -
オブジェクトのインスタンス変数の値を取得して返します。
...ば nil を返します。
@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.instanc......e_variable_get(:@bar) #=> nil
//}
@see Object#instance_variable_set,Object#instance_variables,Object#instance_variable_defined?... -
Object
# instance _ variable _ set(var , value) -> object (12233.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?... -
Module
# class _ variable _ defined?(name) -> bool (12227.0) -
name で与えられた名前のクラス変数がモジュールに存在する場合 true を 返します。
...@param name Symbol か String を指定します。
//emlist[例][ruby]{
class Fred
@@foo = 99
end
Fred.class_variable_defined?(:@@foo) #=> true
Fred.class_variable_defined?(:@@bar) #=> false
Fred.class_variable_defined?('@@foo') #=> true
Fred.class_variable_defined?('@@bar') #=> fals... -
Object
# remove _ instance _ variable(name) -> object (12227.0) -
オブジェクトからインスタンス変数 name を取り除き、そのインス タンス変数に設定されていた値を返します。
...ます。
@raise NameError オブジェクトがインスタンス変数 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 (NameErr......or)
end
end
Foo.new.foo
//}
@see Module#remove_class_variable,Module#remove_const... -
Thread
# thread _ variable?(key) -> bool (12227.0) -
引数 key で指定した名前のスレッドローカル変数が存在する場合に true、そ うでない場合に false を返します。
...ram key 変数名を String か Symbol で指定します。
me = Thread.current
me.thread_variable_set(:oliver, "a")
me.thread_variable?(:oliver) # => true
me.thread_variable?(:stanley) # => false
[注意]: Thread#[] でセットしたローカル変数(Fiber ローカル変数)......が
対象ではない事に注意してください。
@see Thread#thread_variable_get, Thread#[]...