るりまサーチ

最速Rubyリファレンスマニュアル検索!
189件ヒット [101-189件を表示] (0.038秒)
トップページ > クエリ:Ruby[x] > 種類:インスタンスメソッド[x] > クエリ:end[x] > クラス:TracePoint[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< < 1 2 >>

TracePoint#disable { ... } -> object (20.0)

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

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

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

//emlist[例][ruby]{
trace.enabled? # => true
trace.disable # => false (実行前...
...スが無効になります。
この場合はブロックの評価結果を返します。

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

trace.disable do
trace.enabled? # => false
end


trace.enabled? # => true
//}

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

trace.enable { p trace.lineno }
# => RuntimeError: access from outside

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

TracePoint#eval_script -> String | nil (20.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#event -> Symbol (20.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 (20.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#lineno -> Integer (20.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 (20.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 (20.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

//}...

TracePoint#return_value -> object (20.0)

メソッドやブロックの戻り値を返します。

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

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

trace = TracePoint.new(:return) do |tp|
p tp.return_value # => 1
end

trace.enable
foo 1
//}...
<< < 1 2 >>