Class: ArtirixDataModels::Aggregation
- Inherits:
-
CommonAggregation
- Object
- CommonAggregation
- ArtirixDataModels::Aggregation
- Includes:
- Enumerable
- Defined in:
- lib/artirix_data_models/aggregation.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Value
Constant Summary
Constants included from WithDAORegistry
WithDAORegistry::DEFAULT_DAO_REGISTRY_LOADER
Constants included from Inspectable
Instance Attribute Summary collapse
-
#buckets ⇒ Object
Returns the value of attribute buckets.
Attributes inherited from CommonAggregation
Attributes included from WithDAORegistry
Instance Method Summary collapse
- #calculate_filtered(filtered_values = []) ⇒ Object
- #data_hash ⇒ Object
- #filtered_buckets ⇒ Object
- #filtered_first_buckets ⇒ Object
-
#initialize(name, buckets) ⇒ Aggregation
constructor
A new instance of Aggregation.
- #non_empty_buckets ⇒ Object
- #unfiltered_buckets ⇒ Object
Methods inherited from CommonAggregation
Methods included from WithDAORegistry
#dao_registry, #dao_registry=, #default_dao_registry, loader_or_registry_or_default, #set_dao_registry, #set_dao_registry_and_loader, #set_dao_registry_loader, #set_default_dao_registry_loader
Methods included from Inspectable
#data_hash_for_inspect, #inspect, #inspect_with_tab
Constructor Details
#initialize(name, buckets) ⇒ Aggregation
Returns a new instance of Aggregation.
39 40 41 42 |
# File 'lib/artirix_data_models/aggregation.rb', line 39 def initialize(name, buckets) super name @buckets = buckets end |
Instance Attribute Details
#buckets ⇒ Object
Returns the value of attribute buckets.
37 38 39 |
# File 'lib/artirix_data_models/aggregation.rb', line 37 def buckets @buckets end |
Instance Method Details
#calculate_filtered(filtered_values = []) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/artirix_data_models/aggregation.rb', line 57 def calculate_filtered(filtered_values = []) buckets.each do |b| b.filtered = filtered_values.include?(b.name) end self end |
#data_hash ⇒ Object
50 51 52 53 54 55 |
# File 'lib/artirix_data_models/aggregation.rb', line 50 def data_hash { name: name, buckets: buckets.map(&:data_hash) } end |
#filtered_buckets ⇒ Object
65 66 67 |
# File 'lib/artirix_data_models/aggregation.rb', line 65 def filtered_buckets buckets.select &:filtered? end |
#filtered_first_buckets ⇒ Object
73 74 75 |
# File 'lib/artirix_data_models/aggregation.rb', line 73 def filtered_first_buckets filtered_buckets + unfiltered_buckets end |
#non_empty_buckets ⇒ Object
46 47 48 |
# File 'lib/artirix_data_models/aggregation.rb', line 46 def non_empty_buckets buckets.reject { |x| x.empty? } end |
#unfiltered_buckets ⇒ Object
69 70 71 |
# File 'lib/artirix_data_models/aggregation.rb', line 69 def unfiltered_buckets buckets.reject &:filtered? end |