Class: Calculon::MultiGroupingResults
- Defined in:
- lib/calculon/results.rb
Instance Attribute Summary
Attributes inherited from Results
Instance Method Summary collapse
Methods inherited from Results
create, #groupings, #initialize, #map_each_time, #time_format
Constructor Details
This class inherits a constructor from Calculon::Results
Instance Method Details
#to_a ⇒ Object
79 80 81 82 83 |
# File 'lib/calculon/results.rb', line 79 def to_a map_each_time { |key| fetch(key, []) } end |
#values_for(grouping, default = nil) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/calculon/results.rb', line 85 def values_for(grouping, default = nil) map_each_time { |key| matches = fetch(key, []).select { |value| grouping.map { |k, v| value.send(k) == v }.all? } matches.length > 0 ? matches.first : default } end |