class SourceRoute::TraceChain

delegate to Array

Attributes

chain[R]

Public Class Methods

new() click to toggle source
# File lib/source_route/trace_chain.rb, line 11
def initialize
  @chain = []
end

Public Instance Methods

call_chain() click to toggle source
# File lib/source_route/trace_chain.rb, line 15
def call_chain
  select(&:call_event?)
end
import_return_value_to_call_chain() click to toggle source
# File lib/source_route/trace_chain.rb, line 23
def import_return_value_to_call_chain
  call_chain.each do |ctp|
    matched_return_tp = return_chain.reject(&:matched?).detect {|rtp| rtp == ctp}
    unless matched_return_tp.nil?
      matched_return_tp.return_tp_assign_call_tp(ctp)
    end
  end
end
parent_length_list() click to toggle source

seems not used in html template now 2015.9.17

# File lib/source_route/trace_chain.rb, line 55
def parent_length_list
  call_chain.map { |tp| tp.parent_length }.uniq.sort
end
return_chain() click to toggle source
# File lib/source_route/trace_chain.rb, line 19
def return_chain
  select(&:return_event?)
end
treeize_call_chain() click to toggle source
# File lib/source_route/trace_chain.rb, line 32
def treeize_call_chain
  init_order_id_and_parent_ids
  call_chain.each do |tpr|
    # find the return trace point for the call trace point
    return_tpr = return_chain.reject(&:locate_opposite?).find { |rtpr| rtpr == tpr }
    # so trace points between the call trace point and its return trace point
    # are all children of it
    unless return_tpr.nil?
      return_tpr.found_opposite
      start_index, end_index = tpr.order_id, return_tpr.order_id
      unless end_index == start_index + 1
        values_at(start_index+1 ... end_index).select(&:call_event?).each do |ct|
          ct.parent_ids.push start_index
          tpr.direct_child_order_ids.push ct.order_id
        end
      end
    end
  end

  cal_parent_length
end

Private Instance Methods

cal_parent_length() click to toggle source
# File lib/source_route/trace_chain.rb, line 66
def cal_parent_length
  each do |tpr|
    tpr.parent_length = tpr.parent_ids.length
  end
end
init_order_id_and_parent_ids() click to toggle source
# File lib/source_route/trace_chain.rb, line 60
def init_order_id_and_parent_ids
  each_with_index do |tpr, index|
    tpr.order_id, tpr.parent_ids, tpr.direct_child_order_ids = index, [], []
  end
end