Class: CommaPile::PivotNode

Inherits:
Hash
  • Object
show all
Defined in:
lib/comma_pile/pivot_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePivotNode

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

#counterObject



9
# File 'lib/comma_pile/pivot_node.rb', line 9

def counter; @counter ||= 0; end

#sumObject (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

#inspectObject



11
12
13
# File 'lib/comma_pile/pivot_node.rb', line 11

def inspect
  "(counter: #{counter}; hash:#{super})"
end