種類
- インスタンスメソッド (99)
- モジュール関数 (66)
- 定数 (11)
- 特異メソッド (11)
クラス
- Binding (28)
- Object (11)
- Proc (11)
-
RubyVM
:: InstructionSequence (11) - Thread (38)
- TracePoint (22)
モジュール
- Kernel (44)
- ObjectSpace (22)
キーワード
-
TOPLEVEL
_ BINDING (11) -
add
_ trace _ func (11) -
define
_ finalizer (22) - eval (33)
-
local
_ variable _ set (11) - of (11)
-
report
_ on _ exception (8) -
report
_ on _ exception= (8) - self (11)
-
set
_ trace _ func (22) -
source
_ location (6)
検索結果
先頭5件
-
TracePoint
# binding -> Binding | nil (21238.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...れた Binding オブジェクトを返します。
C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:......call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
TracePoint
# binding -> Binding (21232.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...発生したイベントによって生成された Binding オブジェクトを返します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
Proc
# binding -> Binding (21226.0) -
Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。
...
Proc オブジェクトが保持するコンテキストを
Binding オブジェクトで返します。
//emlist[例][ruby]{
def fred(param)
proc {}
end
sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}... -
Kernel
. # binding -> Binding (18238.0) -
変数・メソッドなどの環境情報を含んだ Binding オブジェクトを 生成して返します。通常、Kernel.#eval の第二引数として使います。
...変数・メソッドなどの環境情報を含んだ Binding オブジェクトを
生成して返します。通常、Kernel.#eval の第二引数として使います。
//emlist[例][ruby]{
def foo
a = 1
binding
end
eval("p a", foo) #=> 1
//}
@see Kernel.#eval,Object::TOPLEVEL_BINDING... -
Object
:: TOPLEVEL _ BINDING -> Binding (12326.0) -
トップレベルでの Binding オブジェクト。
...トップレベルでの Binding オブジェクト。
詳細は Binding を参照してください。... -
Binding
# eval(expr , fname = _ _ FILE _ _ , lineno = 1) -> object (9132.0) -
自身をコンテキストとし文字列 expr を Ruby プログラムとして評価しその結果を返します。 組み込み関数 Kernel.#eval を使って eval(expr, self, fname, lineno) とするのと同じです。
...ストとし文字列 expr を
Ruby プログラムとして評価しその結果を返します。
組み込み関数 Kernel.#eval を使って
eval(expr, self, fname, lineno) とするのと同じです。
@param expr 評価したい式を文字列で与えます。
@param fname ファイル名......expr が fname というファイル名にあるかのように実行されます。
@param lineno 行番号を整数で与えます。式 expr の先頭行の行番号が lineno であるかのように実行されます。
//emlist[例][ruby]{
def get_binding(str)
binding
end
str = "hello"
p e......val("str + ' Fred'") #=> "hello Fred"
p get_binding("bye").eval("str + ' Fred'") #=> "bye Fred"
//}
@see Kernel.#eval... -
Binding
# local _ variable _ set(symbol , obj) (9056.0) -
引数 symbol で指定した名前のローカル変数に引数 obj を設定します。
...を設定します。
@param symbol ローカル変数名を Symbol オブジェクトで指定します。
@param obj 引数 symbol で指定したローカル変数に設定するオブジェクトを指定します。
//emlist[例][ruby]{
def foo
a = 1
bind = binding
bind.local_variable_......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
# source _ location -> [String , Integer] (9014.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
Thread
# report _ on _ exception -> bool (6108.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception #......rb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thr......ead:0x00007fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception... -
Thread
# report _ on _ exception=(newstate) (6108.0) -
真の場合、そのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...Thread.report_on_exception です。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。
//emlist[例][ruby]{
a = Thread.new{ Thread.stop; raise }
a.report_on_exception = true
a.report_on_exception #......rb):1 run> terminated with exception (report_on_exception is true):
# Traceback (most recent call last):
# (irb):1:in `block in irb_binding': unhandled exception
# #<Thread:0x00007fc3f48c7908@(irb):1 dead>
b = Thread.new{ Thread.stop; raise }
b.report_on_exception = false
b.run # => #<Thr......ead:0x00007fc3f48aefc0@(irb):4 dead>
//}
@see Thread.report_on_exception... -
ObjectSpace
. # define _ finalizer(obj , proc) -> Array (3108.0) -
obj が解放されるときに実行されるファイナライザ proc を 登録します。同じオブジェクトについて複数回呼ばれたときは置き換えで はなく追加登録されます。固定値 0 と proc を配列にして返します。
...obj が解放されるときに実行されるファイナライザ proc を
登録します。同じオブジェクトについて複数回呼ばれたときは置き換えで
はなく追加登録されます。固定値 0 と proc を配列にして返します。
ブロックを指定した場......ナライザを登録するのは難しいでしょう。
@param obj ファイナライザを登録したいオブジェクトを指定します。
@param proc ファイナライザとして Proc オブジェクトを指定します。proc は obj の回収時に obj の ID を引数として実......s Foo
def initialize
ObjectSpace.define_finalizer(self) {
puts "foo"
}
end
end
Foo.new
GC.start
//}
これは、渡された proc の self が obj を参照しつ
づけるため。そのオブジェクトが GC の対象になりません。
tempfile は、ファイナライザ... -
TracePoint
# self -> object (3020.0) -
イベントを発生させたオブジェクトを返します。
...返します。
以下のようにする事で同じ値を取得できます。
なお、self メソッドは binding が nil になる :c_call および :c_return イベントに対しても正しく動作します。
//emlist[例][ruby]{
trace.binding.eval('self')
//}
@see TracePoint#binding...