Class: Thread::Backtrace::Location
Instance Method Summary collapse
-
#absolute_path ⇒ Object
Returns the full file path of this frame.
-
#base_label ⇒ Object
Returns the base label of this frame, which is usually equal to the label, without decoration.
-
#inspect ⇒ Object
Returns the same as calling
inspect
on the string representation of #to_str. -
#label ⇒ Object
Returns the label of this frame.
-
#lineno ⇒ Object
Returns the line number of this frame.
-
#path ⇒ Object
Returns the file name of this frame.
-
#to_s ⇒ Object
Returns a Kernel#caller style string representing this frame.
Instance Method Details
#absolute_path ⇒ Object
Returns the full file path of this frame.
Same as #path, except that it will return absolute path even if the frame is in the main script.
438 439 440 441 442 |
# File 'vm_backtrace.c', line 438
static VALUE
location_absolute_path_m(VALUE self)
{
return location_realpath(location_ptr(self));
}
|
#base_label ⇒ Object
Returns the base label of this frame, which is usually equal to the label, without decoration.
Consider the following example:
def foo
puts caller_locations(0).first.base_label
1.times do
puts caller_locations(0).first.base_label
1.times do
puts caller_locations(0).first.base_label
end
end
end
The result of calling foo
is this:
foo foo foo
364 365 366 367 368 |
# File 'vm_backtrace.c', line 364
static VALUE
location_base_label_m(VALUE self)
{
return location_base_label(location_ptr(self));
}
|
#inspect ⇒ Object
Returns the same as calling inspect
on the string representation of #to_str
503 504 505 506 507 |
# File 'vm_backtrace.c', line 503
static VALUE
location_inspect_m(VALUE self)
{
return rb_str_inspect(location_to_str(location_ptr(self)));
}
|
#label ⇒ Object
Returns the label of this frame.
Usually consists of method, class, module, etc names with decoration.
Consider the following example:
def foo
puts caller_locations(0).first.label
1.times do
puts caller_locations(0).first.label
1.times do
puts caller_locations(0).first.label
end
end
end
The result of calling foo
is this:
foo block in foo block (2 levels) in foo
324 325 326 327 328 |
# File 'vm_backtrace.c', line 324
static VALUE
location_label_m(VALUE self)
{
return location_label(location_ptr(self));
}
|
#lineno ⇒ Object
Returns the line number of this frame.
For example, using caller_locations.rb
from Thread::Backtrace::Location
loc = c(0..1).first loc.lineno #=> 2
196 197 198 199 200 |
# File 'vm_backtrace.c', line 196
static VALUE
location_lineno_m(VALUE self)
{
return INT2FIX(location_lineno(location_ptr(self)));
}
|
#path ⇒ Object
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
loc = c(0..1).first loc.path #=> caller_locations.rb
386 387 388 389 390 391 |
# File 'vm_backtrace.c', line 386
static VALUE
location_path_m(VALUE self)
{
const rb_iseq_t *iseq = location_iseq(location_ptr(self));
return iseq ? rb_iseq_path(iseq) : Qnil;
}
|
#to_s ⇒ Object
Returns a Kernel#caller style string representing this frame.
493 494 495 496 497 |
# File 'vm_backtrace.c', line 493
static VALUE
location_to_str_m(VALUE self)
{
return location_to_str(location_ptr(self));
}
|