Sha256: 10759414a6150b45f772484d4e5cf503c247e74696cebad5bfe2844dba60cd27

Contents?: true

Size: 387 Bytes

Versions: 1

Compression:

Stored size: 387 Bytes

Contents

module PivotTable
  class Column

    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

1 entries across 1 versions & 1 rubygems

Version Path
pivot_table-0.1.3 lib/pivot_table/column.rb