Class: Reportability::Summary
- Inherits:
-
Object
- Object
- Reportability::Summary
- Defined in:
- lib/reportability/summary.rb
Instance Method Summary collapse
-
#initialize(level_fields, always_fields, value_fields, aggregates = {}) ⇒ Summary
constructor
level_fields - group by fields alawys_fields - those must always be present in output value_fields - those are summarized.
- #inspect ⇒ Object
- #push(row) ⇒ Object
-
#summary ⇒ Object
flattens the output.
Constructor Details
#initialize(level_fields, always_fields, value_fields, aggregates = {}) ⇒ Summary
level_fields - group by fields alawys_fields - those must always be present in output value_fields - those are summarized
6 7 8 9 10 11 12 |
# File 'lib/reportability/summary.rb', line 6 def initialize(level_fields, always_fields, value_fields, aggregates={}) @level_fields = level_fields @always_fields = always_fields @value_fields = value_fields @levels = {} @aggregates = Hash.new(default_aggregate).merge(aggregates) end |
Instance Method Details
#inspect ⇒ Object
25 26 27 |
# File 'lib/reportability/summary.rb', line 25 def inspect @levels end |
#push(row) ⇒ Object
14 15 16 17 18 |
# File 'lib/reportability/summary.rb', line 14 def push(row) @level_fields.each do |e| update_level(e, row) end end |
#summary ⇒ Object
flattens the output
21 22 23 |
# File 'lib/reportability/summary.rb', line 21 def summary @levels.map { |k, v| k.merge(v) } end |