別のキーワード
種類
- インスタンスメソッド (95)
- 特異メソッド (11)
ライブラリ
- ビルトイン (106)
キーワード
-
callee
_ id (11) -
eval
_ script (6) - event (11)
-
instruction
_ sequence (6) - lineno (11)
-
method
_ id (11) - parameters (6)
- path (11)
-
raised
_ exception (11) -
return
_ value (11)
検索結果
先頭5件
-
TracePoint
. new(*events) {|obj| . . . } -> TracePoint (18132.0) -
新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。
...新しい TracePoint オブジェクトを作成して返します。トレースを有効
にするには TracePoint#enable を実行してください。
//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.even......t]
end
# => #<TracePoint:0x007f17372cdb20>
trace.enable
# => false
puts "Hello, TracePoint!"
# ...
# [69, IRB::Notifier::AbstractNotifier, :printf, :call]
# ...
//}
トレースを無効にするには TracePoint#disable を実行してください。
//emlist[][ruby]{
trace.disable
//}
@param......トに関連しない情報を取得するメソッドを実行した場合には
RuntimeError が発生します。
//emlist[例][ruby]{
TracePoint.trace(:line) do |tp|
p tp.raised_exception
end
# => RuntimeError: 'raised_exception' not supported by this event
//}
イベントフックの外... -
TracePoint
# callee _ id -> Symbol | nil (19.0) -
イベントが発生したメソッドの呼ばれた名前を Symbol で返します。 トップレベルであった場合は nil を返します。
...であった場合は nil を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[][ruby]{
class C
def method_name
end
alias alias_name method_name
end
trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # =......> [:method_name, :alias_name]
end
trace.enable do
C.new.alias_name
end
//}
@see TracePoint#method_id... -
TracePoint
# event -> Symbol (19.0) -
発生したイベントの種類を Symbol で返します。
...するイベントの詳細については、TracePoint.new を参照してくださ
い。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
p tp.event
end
trace... -
TracePoint
# method _ id -> Symbol | nil (19.0) -
イベントが発生したメソッドの定義時の名前を Symbol で返します。 トップレベルであった場合は nil を返します。
...であった場合は nil を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[][ruby]{
class C
def method_name
end
alias alias_name method_name
end
trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # =......> [:method_name, :alias_name]
end
trace.enable do
C.new.alias_name
end
//}
@see TracePoint#callee_id... -
TracePoint
# eval _ script -> String | nil (13.0) -
script_compiledイベント発生時にコンパイルされたソースコードを返します。 ファイルから読み込んだ場合は、nilを返します。
...から読み込んだ場合は、nilを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end.enable do
eval("puts 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフ... -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (13.0) -
script_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 イベントのための... -
TracePoint
# lineno -> Integer (13.0) -
発生したイベントの行番号を返します。
...発生したイベントの行番号を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
tp.lineno
end
trace.enable
foo 1
# => 1
# 3
//}... -
TracePoint
# parameters -> [object] (13.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.pa... -
TracePoint
# path -> String (13.0) -
イベントが発生したファイルのパスを返します。
...ベントが発生したファイルのパスを返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1... -
TracePoint
# raised _ exception -> Exception (13.0) -
発生した例外を返します。
...発生した例外を返します。
@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。
//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided... -
TracePoint
# return _ value -> object (13.0) -
メソッドやブロックの戻り値を返します。
...戻り値を返します。
@raise RuntimeError :return、:c_return、:b_return イベントのためのイベ
ントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:return) do |tp|
p tp.return_va...