Class: Bigbertha::Snapshot::Node
- Inherits:
-
Object
- Object
- Bigbertha::Snapshot::Node
- Defined in:
- lib/bigbertha/snapshot.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
- #dump ⇒ Object
-
#initialize(name) ⇒ Node
constructor
A new instance of Node.
- #to_map ⇒ Object
Constructor Details
#initialize(name) ⇒ Node
Returns a new instance of Node.
7 8 9 10 11 12 13 |
# File 'lib/bigbertha/snapshot.rb', line 7 def initialize( name ) @name = name @priority = nil @children = [] @value = nil @parent = nil end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/bigbertha/snapshot.rb', line 5 def children @children end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/bigbertha/snapshot.rb', line 5 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/bigbertha/snapshot.rb', line 5 def parent @parent end |
#priority ⇒ Object
Returns the value of attribute priority.
5 6 7 |
# File 'lib/bigbertha/snapshot.rb', line 5 def priority @priority end |
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/bigbertha/snapshot.rb', line 5 def value @value end |
Instance Method Details
#add_child(child) ⇒ Object
15 16 17 18 |
# File 'lib/bigbertha/snapshot.rb', line 15 def add_child( child ) child.parent = self children << child end |
#dump ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bigbertha/snapshot.rb', line 26 def dump puts "#{' '*level}#{name} [#{priority.inspect}] --#{value.inspect}" children.sort_by do |c| if c.priority and c.priority.is_a? Integer "b_#{c.priority}_#{c.name}" elsif c.priority "z_#{c.priority}_#{c.name}" else "a_#{c.name}" end end.each do |c| c.dump end end |
#to_map ⇒ Object
20 21 22 23 24 |
# File 'lib/bigbertha/snapshot.rb', line 20 def to_map map = Map.new order( map ) map end |