Class: ReportsKit::Reports::Data::AggregateComposite
- Inherits:
-
Object
- Object
- ReportsKit::Reports::Data::AggregateComposite
- Defined in:
- lib/reports_kit/reports/data/aggregate_composite.rb
Constant Summary collapse
- OPERATORS_METHODS =
{ '+' => :+, '-' => :-, '*' => :*, '/' => :/, '%' => -> (values) { raise ArgumentError.new('Percentage composite aggregations must have exactly two series') if values.length != 2 numerator, denominator = values return 0 if denominator == 0 ((numerator.to_f / denominator) * 100).round(1) } }
Instance Attribute Summary collapse
-
#composite_series ⇒ Object
Returns the value of attribute composite_series.
-
#context_record ⇒ Object
Returns the value of attribute context_record.
Instance Method Summary collapse
-
#initialize(properties, context_record:) ⇒ AggregateComposite
constructor
A new instance of AggregateComposite.
- #perform ⇒ Object
Constructor Details
#initialize(properties, context_record:) ⇒ AggregateComposite
Returns a new instance of AggregateComposite.
22 23 24 25 |
# File 'lib/reports_kit/reports/data/aggregate_composite.rb', line 22 def initialize(properties, context_record:) self.composite_series = CompositeSeries.new(properties, context_record: context_record) self.context_record = context_record end |
Instance Attribute Details
#composite_series ⇒ Object
Returns the value of attribute composite_series.
5 6 7 |
# File 'lib/reports_kit/reports/data/aggregate_composite.rb', line 5 def composite_series @composite_series end |
#context_record ⇒ Object
Returns the value of attribute context_record.
5 6 7 |
# File 'lib/reports_kit/reports/data/aggregate_composite.rb', line 5 def context_record @context_record end |
Instance Method Details
#perform ⇒ Object
27 28 29 30 31 |
# File 'lib/reports_kit/reports/data/aggregate_composite.rb', line 27 def perform return serieses_results_for_one_dimension if dimension_count == 1 return serieses_results_for_two_dimensions if dimension_count == 2 raise ArgumentError.new("Composite aggregations' series can only have 1-2 dimensions") end |