Class: TraceViz::TraceData::TracePoint::MethodReturn

Inherits:
Base
  • Object
show all
Defined in:
lib/trace_viz/trace_data/trace_point/method_return.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#action, #event, #klass, #line_number, #memory_id, #path, #trace_point

Attributes included from TraceViz::Traits::Identifiable

#action_id, #id

Attributes inherited from Node

#children, #parent

Attributes included from TraceViz::Traits::TimeTrackable

#timestamp

Attributes included from TraceViz::Traits::DepthTrackable

#depth

Instance Method Summary collapse

Methods inherited from Base

#key

Methods included from TraceViz::Traits::Identifiable

#assign_ids

Methods inherited from Node

#add_child, #add_children

Methods inherited from Base

#action, #event, #key, #klass, #line_number, #path

Methods included from TraceViz::Traits::TimeTrackable

#record_timestamp

Methods included from TraceViz::Traits::DepthTrackable

#assign_depth

Methods included from Helpers::ConfigHelper

#config, #fetch_general_config

Constructor Details

#initialize(trace_point) ⇒ MethodReturn

Returns a new instance of MethodReturn.



11
12
13
14
15
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 11

def initialize(trace_point)
  super(trace_point)

  populate_result
end

Instance Attribute Details

#method_callObject (readonly)

Returns the value of attribute method_call.



9
10
11
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 9

def method_call
  @method_call
end

#resultObject (readonly)

Returns the value of attribute result.



9
10
11
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 9

def result
  @result
end

Instance Method Details

#durationObject



22
23
24
25
26
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 22

def duration
  return 0 unless method_call

  timestamp - method_call.timestamp
end


17
18
19
20
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 17

def link(method_call)
  @method_call = method_call
  method_call.link(self)
end

#to_hObject



28
29
30
31
32
33
34
35
# File 'lib/trace_viz/trace_data/trace_point/method_return.rb', line 28

def to_h
  super.merge(
    {
      result: result,
      method_call_id: method_call&.id,
    },
  )
end