Module: PivotTable::CellCollection

Included in:
Column, Row
Defined in:
lib/pivot_table/cell_collection.rb

Constant Summary collapse

ACCESSORS =
[:header, :data, :value_name, :orthogonal_headers]

Instance Method Summary collapse

Instance Method Details

#initialize(options = {}) ⇒ Object



10
11
12
13
14
# File 'lib/pivot_table/cell_collection.rb', line 10

def initialize(options = {})
  ACCESSORS.each do |a|
    self.send("#{a}=", options[a]) if options.has_key?(a)
  end
end

#totalObject



16
17
18
# File 'lib/pivot_table/cell_collection.rb', line 16

def total
  data.inject(0) { |t, x| t + (x ? x.send(value_name) : 0) }
end