Class: Cuporter::NodeNumberer
- Inherits:
-
Object
- Object
- Cuporter::NodeNumberer
- Defined in:
- lib/cuporter/node_numberer.rb
Instance Attribute Summary collapse
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize ⇒ NodeNumberer
constructor
A new instance of NodeNumberer.
- #number(node) ⇒ Object
Constructor Details
#initialize ⇒ NodeNumberer
Returns a new instance of NodeNumberer.
6 7 8 |
# File 'lib/cuporter/node_numberer.rb', line 6 def initialize @total = 0 end |
Instance Attribute Details
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/cuporter/node_numberer.rb', line 4 def total @total end |
Instance Method Details
#number(node) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/cuporter/node_numberer.rb', line 10 def number(node) node.children.each do |child| child.number = @total += 1 if child.numerable? number(child) end end |