lib/pivot_table/column.rb in pivot_table-0.1.1 vs lib/pivot_table/column.rb in pivot_table-0.1.3
- old
+ new
@@ -1,9 +1,9 @@
module PivotTable
class Column
- ACCESSORS = [:header, :data, :total]
+ ACCESSORS = [:header, :data, :value_name]
ACCESSORS.each do |a|
self.send(:attr_accessor, a)
end
@@ -11,7 +11,11 @@
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
\ No newline at end of file
+end