Class: TraceLocation::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/trace_location/event.rb

Overview

:nodoc:

Constant Summary collapse

CLASS_FORMAT =
/\A#<(?:Class|refinement)\:([A-Za-z0-9\:]+).*>\z/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, event:, path:, lineno:, caller_path:, caller_lineno:, owner:, name:, source:, hierarchy:, is_module:) ⇒ Event



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/trace_location/event.rb', line 8

def initialize(id:, event:, path:, lineno:, caller_path:, caller_lineno:, owner:, name:, source:, hierarchy:, is_module:)
  @id = id
  @event = event
  @path = path
  @lineno = lineno
  @caller_path = caller_path
  @caller_lineno = caller_lineno
  @owner = owner
  @name = name
  @source = source
  @hierarchy = hierarchy.to_i
  @is_module = is_module
end

Instance Attribute Details

#caller_linenoObject (readonly)

Returns the value of attribute caller_lineno.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def caller_lineno
  @caller_lineno
end

#caller_pathObject (readonly)

Returns the value of attribute caller_path.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def caller_path
  @caller_path
end

#eventObject (readonly)

Returns the value of attribute event.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def event
  @event
end

#hierarchyObject (readonly)

Returns the value of attribute hierarchy.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def hierarchy
  @hierarchy
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def id
  @id
end

#is_moduleObject (readonly)

Returns the value of attribute is_module.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def is_module
  @is_module
end

#linenoObject (readonly)

Returns the value of attribute lineno.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def lineno
  @lineno
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def owner
  @owner
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def path
  @path
end

#sourceObject (readonly)

Returns the value of attribute source.



6
7
8
# File 'lib/trace_location/event.rb', line 6

def source
  @source
end

Instance Method Details

#call?Boolean



30
31
32
# File 'lib/trace_location/event.rb', line 30

def call?
  event == :call
end

#invalid?Boolean



26
27
28
# File 'lib/trace_location/event.rb', line 26

def invalid?
  !valid?
end

#owner_with_nameObject



38
39
40
41
42
# File 'lib/trace_location/event.rb', line 38

def owner_with_name
  match = owner.to_s.match(CLASS_FORMAT)
  separator = is_module ? '.' : '#'
  match ? "#{match[1]}#{separator}#{name}" : "#{owner}#{separator}#{name}"
end

#return?Boolean



34
35
36
# File 'lib/trace_location/event.rb', line 34

def return?
  event == :return
end

#valid?Boolean



22
23
24
# File 'lib/trace_location/event.rb', line 22

def valid?
  hierarchy >= 0
end