Class: CommaPile::PivotNode
- Inherits:
-
Hash
- Object
- Hash
- CommaPile::PivotNode
- Defined in:
- lib/comma_pile/pivot_node.rb
Instance Attribute Summary collapse
- #counter ⇒ Object
-
#sum ⇒ Object
readonly
Returns the value of attribute sum.
Instance Method Summary collapse
- #add_to(fieldname, value) ⇒ Object
-
#initialize ⇒ PivotNode
constructor
A new instance of PivotNode.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ PivotNode
Returns a new instance of PivotNode.
4 5 6 |
# File 'lib/comma_pile/pivot_node.rb', line 4 def initialize @sum = {} end |
Instance Attribute Details
#counter ⇒ Object
9 |
# File 'lib/comma_pile/pivot_node.rb', line 9 def counter; @counter ||= 0; end |
#sum ⇒ Object (readonly)
Returns the value of attribute sum.
3 4 5 |
# File 'lib/comma_pile/pivot_node.rb', line 3 def sum @sum end |
Instance Method Details
#add_to(fieldname, value) ⇒ Object
15 16 17 18 |
# File 'lib/comma_pile/pivot_node.rb', line 15 def add_to(fieldname, value) self.sum[fieldname] ||= 0 self.sum[fieldname] += value end |
#inspect ⇒ Object
11 12 13 |
# File 'lib/comma_pile/pivot_node.rb', line 11 def inspect "(counter: #{counter}; hash:#{super})" end |