Class: ArtirixDataModels::Aggregation
Defined Under Namespace
Classes: Value
Constant Summary
Constants included
from Inspectable
Inspectable::SPACE
Instance Attribute Summary collapse
#name
Instance Method Summary
collapse
from_json, #pretty_name
#data_hash_for_inspect, #inspect, #inspect_with_tab
Constructor Details
#initialize(name, buckets) ⇒ Aggregation
Returns a new instance of Aggregation.
34
35
36
37
|
# File 'lib/artirix_data_models/aggregation.rb', line 34
def initialize(name, buckets)
super name
@buckets = buckets
end
|
Instance Attribute Details
#buckets ⇒ Object
Returns the value of attribute buckets.
32
33
34
|
# File 'lib/artirix_data_models/aggregation.rb', line 32
def buckets
@buckets
end
|
Instance Method Details
#calculate_filtered(filtered_values = []) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/artirix_data_models/aggregation.rb', line 52
def calculate_filtered(filtered_values = [])
buckets.each do |b|
b.filtered = filtered_values.include?(b.name)
end
self
end
|
#data_hash ⇒ Object
45
46
47
48
49
50
|
# File 'lib/artirix_data_models/aggregation.rb', line 45
def data_hash
{
name: name,
buckets: buckets.map(&:data_hash)
}
end
|
#filtered_buckets ⇒ Object
60
61
62
|
# File 'lib/artirix_data_models/aggregation.rb', line 60
def filtered_buckets
buckets.select &:filtered?
end
|
#filtered_first_buckets ⇒ Object
68
69
70
|
# File 'lib/artirix_data_models/aggregation.rb', line 68
def filtered_first_buckets
filtered_buckets + unfiltered_buckets
end
|
#non_empty_buckets ⇒ Object
41
42
43
|
# File 'lib/artirix_data_models/aggregation.rb', line 41
def non_empty_buckets
buckets.reject { |x| x.empty? }
end
|
#unfiltered_buckets ⇒ Object
64
65
66
|
# File 'lib/artirix_data_models/aggregation.rb', line 64
def unfiltered_buckets
buckets.reject &:filtered?
end
|