るりまサーチ

最速Rubyリファレンスマニュアル検索!
248件ヒット [101-200件を表示] (0.019秒)
トップページ > クエリ:end[x] > クエリ:TracePoint[x]

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. io seek_end

検索結果

<< < 1 2 3 > >>

TracePoint#enable { ... } -> object (21024.0)

self のトレースを有効にします。

...self のトレースを有効にします。

実行前の TracePoint#enabled? を返します。(トレースが既に有効であっ
た場合は true を返します。そうでなければ false を返します)

//emlist[例][ruby]{
trace.enabled? # => false
trace.enable # => false (実行...
...場合はブロックの評価結果を返します。

//emlist[例][ruby]{
trace.enabled? # => false

trace.enable do
trace.enabled? # => true
end


trace.enabled? # => false
//}

[注意] イベントフックのためのメソッドにブロックの外側で参照した場合は
RuntimeErr...
...or が発生する事に注意してください。

//emlist[例][ruby]{
trace.enable { p trace.lineno }
# => RuntimeError: access from outside
//}

@see TracePoint#disable, TracePoint#enabled?...

TracePoint#event -> Symbol (21024.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.enable
foo 1
# => :c...

TracePoint#inspect -> String (21024.0)

self の状態を人間に読みやすい文字列にして返します。

...self の状態を人間に読みやすい文字列にして返します。

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end

trace.enable
foo 1
//}...

TracePoint#parameters -> [object] (21024.0)

現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。

...トのためのイベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(a, b = 2)
end

TracePoint
.new(:call) do |tp|
p tp.parameters # => a], [:opt, :b
end
.enable do
foo(1)
end

//}

@see Method#parameters, UnboundMethod#parameters, Proc#parameters...

TracePoint#binding -> Binding (21018.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
//}...

絞り込み条件を変える

TracePoint#binding -> Binding | nil (21018.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...は 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#eval_script -> String | nil (21018.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 (21018.0)

script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。

...equenceインスタンスを返します。

//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 (21018.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#path -> String (21018.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 (21018.0)

発生した例外を返します。

...eError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。

//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end

trace.enable
begin
0/0
rescue
end

//}...
<< < 1 2 3 > >>