Class: TraceGraph::TraceNode

Inherits:
Object
  • Object
show all
Includes:
TreeGraph
Defined in:
lib/trace_graph/trace_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, is_duplicate: false, class_name: nil) ⇒ TraceNode

Returns a new instance of TraceNode.



14
15
16
17
18
19
# File 'lib/trace_graph/trace_node.rb', line 14

def initialize(label, is_duplicate: false, class_name: nil)
  self.label = label
  self.is_duplicate = is_duplicate
  self.sub_nodes = []
  self.class_name = class_name
end

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



9
10
11
# File 'lib/trace_graph/trace_node.rb', line 9

def class_name
  @class_name
end

#is_duplicateObject

Returns the value of attribute is_duplicate.



8
9
10
# File 'lib/trace_graph/trace_node.rb', line 8

def is_duplicate
  @is_duplicate
end

#labelObject Also known as: label_for_tree_graph

Returns the value of attribute label.



6
7
8
# File 'lib/trace_graph/trace_node.rb', line 6

def label
  @label
end

#sub_nodesObject Also known as: children_for_tree_graph

Returns the value of attribute sub_nodes.



7
8
9
# File 'lib/trace_graph/trace_node.rb', line 7

def sub_nodes
  @sub_nodes
end

Instance Method Details

#<<(child_node) ⇒ Object



21
22
23
# File 'lib/trace_graph/trace_node.rb', line 21

def << child_node
  sub_nodes << child_node
end

#firstObject



29
30
31
# File 'lib/trace_graph/trace_node.rb', line 29

def first
  sub_nodes.first
end

#node_countObject



25
26
27
# File 'lib/trace_graph/trace_node.rb', line 25

def node_count
  sub_nodes.length
end

#secondObject



33
34
35
# File 'lib/trace_graph/trace_node.rb', line 33

def second
  sub_nodes[1]
end