Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Thread::Backtrace::Location#path

path

Returns the file name of this frame. This will generally be an absolute path, unless the frame is in the main script, in which case it will be the script location passed on the command line.

For example, using caller_locations.rb from Thread::Backtrace::Location

Example
loc = c(0..1).first
loc.path #=> caller_locations.rb
See also #lineno #to_s #label also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0