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
26
27
# File 'lib/debugtrace/location.rb', line 14

def initialize(caller_location)
  if caller_location == nil
    @name = 'unknown'
    @path = 'unknown'
    @lineno = 0
  else
    @name = caller_location.label
    if @name.start_with?('Object#')
      @name = caller_location.base_label
    end
    @path = caller_location.path || 'unknown'
    @lineno = caller_location.lineno
  end
end

Instance Attribute Details

#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

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#to_sString

Returns a string representation of this object.

Returns:

  • (String)

    A string representation of this object



32
33
34
# File 'lib/debugtrace/location.rb', line 32

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