60件ヒット
[1-60件を表示]
(0.115秒)
ライブラリ
- ビルトイン (60)
キーワード
-
instance
_ variables (12) -
local
_ variable _ defined? (12) -
local
_ variable _ get (12) -
local
_ variable _ set (12)
検索結果
先頭5件
-
Binding
# eval(expr , fname = _ _ FILE _ _ , lineno = 1) -> object (18164.0) -
自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。
...コンテキストとし文字列 expr を
Ruby プログラムとして評価しその結果を返します。
組み込み関数 Kernel.#eval を使って
eval(expr, self, fname, lineno) とするのと同じです。
@param expr 評価したい式を文字列で与えます。
@param fname フ......の先頭行の行番号が lineno であるかのように実行されます。
//emlist[例][ruby]{
def get_binding(str)
binding
end
str = "hello"
p eval("str + ' Fred'") #=> "hello Fred"
p get_binding("bye").eval("str + ' Fred'") #=> "bye Fred"
//}
@see Kernel.#eval... -
Binding
# local _ variable _ get(symbol) -> object (6120.0) -
引数 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_var... -
Binding
# local _ variable _ set(symbol , obj) (25.0) -
引数 symbol で指定した名前のローカル変数に引数 obj を設定します。
...set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.local_variable_get(:b) # => 3
p a # => 2
p b # => NameError
end
//}
このメソッド......は以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。
//emlist[][ruby]{
binding.eval("#{symbol} = #{obj}")
//}
@see Binding#local_variable_get, Binding#local_variable_defined?... -
Binding
# local _ variable _ defined?(symbol) -> bool (13.0) -
引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。
...g.local_variable_defined?(:a) # => true
binding.local_variable_defined?(:b) # => false
end
//}
このメソッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("defined?(#{symbol}) == 'local-variable'")
//}
@see Binding#local_variable_get, Binding#local_variable_set... -
Object
# instance _ variables -> [Symbol] (13.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, Module#constants, Module#...