ライブラリ
- ビルトイン (269)
クラス
- BasicObject (44)
- Binding (64)
- Module (44)
- Object (39)
- Proc (22)
-
RubyVM
:: InstructionSequence (22) - String (11)
- TracePoint (23)
キーワード
- binding (11)
-
class
_ eval (11) -
define
_ method (22) - dump (11)
-
eval
_ script (6) -
instance
_ eval (22) -
instance
_ exec (11) -
instance
_ variables (11) -
instruction
_ sequence (6) -
local
_ variable _ defined? (11) -
local
_ variable _ get (11) -
local
_ variable _ set (11) -
local
_ variables (10) -
module
_ eval (11) - receiver (10)
-
respond
_ to? (11) - self (11)
-
singleton
_ method (11) -
singleton
_ method _ undefined (11) -
source
_ location (11) - taint (6)
-
to
_ a (11)
検索結果
先頭5件
-
Binding
# eval(expr , fname = _ _ FILE _ _ , lineno = 1) -> object (32252.0) -
自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。
...ストとし文字列 expr を
Ruby プログラムとして評価しその結果を返します。
組み込み関数 Kernel.#eval を使って
eval(expr, self, fname, lineno) とするのと同じです。
@param expr 評価したい式を文字列で与えます。
@param fname ファイル名......ram lineno 行番号を整数で与えます。式 expr の先頭行の行番号が 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... -
RubyVM
:: InstructionSequence # eval -> object (29108.0) -
self の命令シーケンスを評価してその結果を返します。
...self の命令シーケンスを評価してその結果を返します。
RubyVM::InstructionSequence.compile("1 + 2").eval # => 3... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (20482.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...は instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval 内......。これはメソッド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えま......です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのように実行されます。スタックトレースの
表示などを差し替えることができます。
@param lineno 整数を指定... -
Proc
# binding -> Binding (20407.0) -
Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。
...Proc オブジェクトが保持するコンテキストを
Binding オブジェクトで返します。
//emlist[例][ruby]{
def fred(param)
proc {}
end
sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}... -
BasicObject
# instance _ eval {|obj| . . . } -> object (20282.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...は instance_eval の外側のスコープと、ブロックの評価ではそのブロックの外側のスコープと、共有します。
メソッド定義の中で instance_eval でメソッドを定義した場合は、囲むメソッドが実行されたときに
初めて instance_eval 内......。これはメソッド定義のネストと同じです。
d:spec/def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えま......です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのように実行されます。スタックトレースの
表示などを差し替えることができます。
@param lineno 整数を指定... -
TracePoint
# eval _ script -> String | nil (20214.0) -
script_compiledイベント発生時にコンパイルされたソースコードを返します。 ファイルから読み込んだ場合は、nilを返します。
...script_compiledイベント発生時にコンパイルされたソースコードを返します。
ファイルから読み込んだ場合は、nilを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end.enable do
eval("puts 'he......llo'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。... -
Binding
# local _ variable _ defined?(symbol) -> bool (20107.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... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (17213.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
...cript_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("......puts 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。... -
BasicObject
# singleton _ method _ undefined(name) -> object (17207.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...フックには
Module#method_undefined を使います。
@param name 未定義にされたメソッド名が Symbol で渡されます。
//emlist[例][ruby]{
class Foo
def singleton_method_undefined(name)
puts "singleton method \"#{name}\" was undefined"
end
end
obj = Foo.new
def obj.f......oo
end
def obj.bar
end
class << obj
undef_method :foo
end
obj.instance_eval {undef bar}
#=> singleton method "foo" was undefined
# singleton method "bar" was undefined
//}
@see Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef... -
Binding
# local _ variable _ get(symbol) -> object (17107.0) -
引数 symbol で指定した名前のローカル変数に設定された値を返します。
...mbol オブジェクトで指定します。
@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?...