このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 2.3.0 リファレンスマニュアル

instance method TracePoint#path

path -> String[permalink][rdoc]

イベントが発生したファイルのパスを返します。

[EXCEPTION] RuntimeError:
イベントフックの外側で実行した場合に発生します。
def foo(ret)
  ret
end
trace = TracePoint.new(:call) do |tp|
  p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1