Class: Wonkavision::Plugins::Aggregation::AggregationSpec
- Inherits:
-
Object
- Object
- Wonkavision::Plugins::Aggregation::AggregationSpec
- Defined in:
- lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb
Instance Attribute Summary collapse
-
#aggregations ⇒ Object
readonly
Returns the value of attribute aggregations.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#filter(&block) ⇒ Object
readonly
Returns the value of attribute filter.
-
#measures ⇒ Object
readonly
Returns the value of attribute measures.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #aggregate_all_combinations ⇒ Object (also: #aggregate_by_all)
- #aggregate_by(*aggregation_list) ⇒ Object
- #dimension(*dimension_names, &block) ⇒ Object
-
#initialize(name) ⇒ AggregationSpec
constructor
A new instance of AggregationSpec.
- #matches(message) ⇒ Object
- #measure(*measure_list) ⇒ Object
Constructor Details
#initialize(name) ⇒ AggregationSpec
Returns a new instance of AggregationSpec.
8 9 10 11 12 13 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 8 def initialize(name) @name = name @measures = HashWithIndifferentAccess.new @aggregations = [] @dimensions = HashWithIndifferentAccess.new end |
Instance Attribute Details
#aggregations ⇒ Object (readonly)
Returns the value of attribute aggregations.
6 7 8 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 6 def aggregations @aggregations end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
6 7 8 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 6 def dimensions @dimensions end |
#filter(&block) ⇒ Object (readonly)
Returns the value of attribute filter.
6 7 8 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 6 def filter @filter end |
#measures ⇒ Object (readonly)
Returns the value of attribute measures.
6 7 8 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 6 def measures @measures end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 6 def name @name end |
Instance Method Details
#aggregate_all_combinations ⇒ Object Also known as: aggregate_by_all
31 32 33 34 35 36 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 31 def aggregate_all_combinations dimension_names = dimensions.keys (1..dimension_names.length).each do |combination_size| dimension_names.combination(combination_size).each { |combo| aggregate_by *combo} end end |
#aggregate_by(*aggregation_list) ⇒ Object
27 28 29 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 27 def aggregate_by(*aggregation_list) self.aggregations << aggregation_list.flatten end |
#dimension(*dimension_names, &block) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 15 def dimension(*dimension_names,&block) = dimension_names. || {} dimension_names.flatten.each do |dim| @dimensions[dim] = Dimension.new(dim,,&block) end end |
#matches(message) ⇒ Object
44 45 46 47 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 44 def matches() return true unless filter filter.arity == 0 ? filter.call : filter.call() end |
#measure(*measure_list) ⇒ Object
22 23 24 25 |
# File 'lib/wonkavision/plugins/analytics/aggregation/aggregation_spec.rb', line 22 def measure(*measure_list) = measure_list. || {} measure_list.flatten.each { |m| self.measures[m] = } end |