Sha256: 6825eb99d0435ac5265c83933eb140d857761833eeaec1d147c9e4b34e571e8a

Contents?: true

Size: 400 Bytes

Versions: 2

Compression:

Stored size: 400 Bytes

Contents

module PivotTable
  module CellCollection

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

    ACCESSORS.each do |a|
      self.send(:attr_accessor, a)
    end

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

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pivot_table-0.2.0 lib/pivot_table/cell_collection.rb
pivot_table-0.1.4 lib/pivot_table/cell_collection.rb