Class: Thread::Backtrace::Location

Inherits:
Object
  • Object
show all
Defined in:
vm_backtrace.c

Instance Method Summary collapse

Instance Method Details

#absolute_pathObject

Returns the full file path of this frame.

Same as #path, but includes the absolute path.



323
324
325
326
327
# File 'vm_backtrace.c', line 323

static VALUE
location_absolute_path_m(VALUE self)
{
    return location_realpath(location_ptr(self));
}

#base_labelObject

Returns the base label of this frame.

Usually same as #label, without decoration.



260
261
262
263
264
# File 'vm_backtrace.c', line 260

static VALUE
location_base_label_m(VALUE self)
{
    return location_base_label(location_ptr(self));
}

#inspectObject

Returns the same as calling inspect on the string representation of #to_str



397
398
399
400
401
# File 'vm_backtrace.c', line 397

static VALUE
location_inspect_m(VALUE self)
{
    return rb_str_inspect(location_to_str(location_ptr(self)));
}

#labelObject

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:

label: foo label: block in foo label: block (2 levels) in foo



233
234
235
236
237
# File 'vm_backtrace.c', line 233

static VALUE
location_label_m(VALUE self)
{
    return location_label(location_ptr(self));
}

#linenoObject

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



184
185
186
187
188
# File 'vm_backtrace.c', line 184

static VALUE
location_lineno_m(VALUE self)
{
    return INT2FIX(location_lineno(location_ptr(self)));
}

#pathObject

Returns the file name of this frame.

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

loc = c(0..1).first loc.path #=> caller_locations.rb



293
294
295
296
297
# File 'vm_backtrace.c', line 293

static VALUE
location_path_m(VALUE self)
{
    return location_path(location_ptr(self));
}

#to_sObject

Returns a Kernel#caller style string representing this frame.



387
388
389
390
391
# File 'vm_backtrace.c', line 387

static VALUE
location_to_str_m(VALUE self)
{
    return location_to_str(location_ptr(self));
}