Class: Location

Inherits:
Object
  • Object
show all
Defined in:
lib/debugtrace/location.rb

Overview

Contains source location information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller_location) ⇒ Location

Initializes this object.

Parameters:

  • caller_location (Thread::Backtrace::Location)

    the caller location



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/debugtrace/location.rb', line 14

def initialize(caller_location)
  if caller_location == nil
    @name = 'unknown'
    @filename = 'unknown'
    @lineno = 0
  else
    @name = caller_location.base_label
    path = caller_location.absolute_path || caller_location.path || 'unknown'
    @filename = File.basename(path)
    @lineno = caller_location.lineno
  end
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/debugtrace/location.rb', line 8

def filename
  @filename
end

#linenoObject (readonly)

Returns the value of attribute lineno.



9
10
11
# File 'lib/debugtrace/location.rb', line 9

def lineno
  @lineno
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/debugtrace/location.rb', line 7

def name
  @name
end

Instance Method Details

#to_sString

Returns a string representation of this object.

Returns:

  • (String)

    A string representation of this object



30
31
32
# File 'lib/debugtrace/location.rb', line 30

def to_s()
    return "(Location){name: #{@name}, filename: #{@filename}, lineno: #{@lineno}"
end