Class: TraceViz::TraceData::Node
- Defined in:
- lib/trace_viz/trace_data/node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#parent ⇒ Object
Returns the value of attribute parent.
Attributes included from TraceViz::Traits::TimeTrackable
Attributes included from TraceViz::Traits::DepthTrackable
Instance Method Summary collapse
- #add_child(node) ⇒ Object
- #add_children(nodes) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #to_h ⇒ Object
Methods inherited from Base
#action, #event, #key, #klass, #line_number, #path
Methods included from TraceViz::Traits::TimeTrackable
Methods included from TraceViz::Traits::DepthTrackable
Methods included from Helpers::ConfigHelper
#config, #fetch_general_config
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 16 |
# File 'lib/trace_viz/trace_data/node.rb', line 11 def initialize super() @parent = nil @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/trace_viz/trace_data/node.rb', line 9 def children @children end |
#parent ⇒ Object
Returns the value of attribute parent.
8 9 10 |
# File 'lib/trace_viz/trace_data/node.rb', line 8 def parent @parent end |
Instance Method Details
#add_child(node) ⇒ Object
18 19 20 21 |
# File 'lib/trace_viz/trace_data/node.rb', line 18 def add_child(node) node.parent = self @children << node end |
#add_children(nodes) ⇒ Object
23 24 25 26 27 |
# File 'lib/trace_viz/trace_data/node.rb', line 23 def add_children(nodes) nodes.each do |node| add_child(node) end end |
#to_h ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/trace_viz/trace_data/node.rb', line 29 def to_h super.merge( { parent: parent&.to_s, children: children.map(&:to_h), }, ) end |