Class: ArtirixDataModels::Aggregation::Value
- Inherits:
-
Object
- Object
- ArtirixDataModels::Aggregation::Value
- Defined in:
- lib/artirix_data_models/aggregation.rb
Instance Attribute Summary collapse
-
#aggregation_name ⇒ Object
Returns the value of attribute aggregation_name.
- #aggregations ⇒ Object (also: #nested_aggregations)
-
#count ⇒ Object
Returns the value of attribute count.
-
#filtered ⇒ Object
Returns the value of attribute filtered.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #aggregation(name) ⇒ Object
- #basic_data_hash ⇒ Object
- #data_hash ⇒ Object
- #default_pretty_name ⇒ Object
- #empty? ⇒ Boolean
- #filtered? ⇒ Boolean
-
#initialize(aggregation_name, name, count, aggregations) ⇒ Value
constructor
A new instance of Value.
- #mark_filtered ⇒ Object
- #mark_unfiltered ⇒ Object
- #pretty_name ⇒ Object
Constructor Details
#initialize(aggregation_name, name, count, aggregations) ⇒ Value
Returns a new instance of Value.
77 78 79 80 81 82 |
# File 'lib/artirix_data_models/aggregation.rb', line 77 def initialize(aggregation_name, name, count, aggregations) @aggregation_name = aggregation_name @name = name @count = count @aggregations = aggregations end |
Instance Attribute Details
#aggregation_name ⇒ Object
Returns the value of attribute aggregation_name.
74 75 76 |
# File 'lib/artirix_data_models/aggregation.rb', line 74 def aggregation_name @aggregation_name end |
#aggregations ⇒ Object Also known as: nested_aggregations
84 85 86 |
# File 'lib/artirix_data_models/aggregation.rb', line 84 def aggregations Array(@aggregations) end |
#count ⇒ Object
Returns the value of attribute count.
74 75 76 |
# File 'lib/artirix_data_models/aggregation.rb', line 74 def count @count end |
#filtered ⇒ Object
Returns the value of attribute filtered.
74 75 76 |
# File 'lib/artirix_data_models/aggregation.rb', line 74 def filtered @filtered end |
#name ⇒ Object
Returns the value of attribute name.
74 75 76 |
# File 'lib/artirix_data_models/aggregation.rb', line 74 def name @name end |
Instance Method Details
#aggregation(name) ⇒ Object
103 104 105 106 |
# File 'lib/artirix_data_models/aggregation.rb', line 103 def aggregation(name) n = name.to_sym aggregations.detect { |x| x.name == n } end |
#basic_data_hash ⇒ Object
116 117 118 119 120 121 |
# File 'lib/artirix_data_models/aggregation.rb', line 116 def basic_data_hash { name: name, count: count } end |
#data_hash ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/artirix_data_models/aggregation.rb', line 108 def data_hash basic_data_hash.tap do |h| if aggregations.present? h[:aggregations] = aggregations.map(&:data_hash) end end end |
#default_pretty_name ⇒ Object
95 96 97 |
# File 'lib/artirix_data_models/aggregation.rb', line 95 def default_pretty_name name end |
#empty? ⇒ Boolean
99 100 101 |
# File 'lib/artirix_data_models/aggregation.rb', line 99 def empty? count == 0 end |
#filtered? ⇒ Boolean
131 132 133 |
# File 'lib/artirix_data_models/aggregation.rb', line 131 def filtered? !!@filtered end |
#mark_filtered ⇒ Object
123 124 125 |
# File 'lib/artirix_data_models/aggregation.rb', line 123 def mark_filtered @filtered = true end |
#mark_unfiltered ⇒ Object
127 128 129 |
# File 'lib/artirix_data_models/aggregation.rb', line 127 def mark_unfiltered @filtered = false end |
#pretty_name ⇒ Object
91 92 93 |
# File 'lib/artirix_data_models/aggregation.rb', line 91 def pretty_name @pretty_name ||= load_pretty_name end |