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.
82 83 84 85 86 87 |
# File 'lib/artirix_data_models/aggregation.rb', line 82 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.
79 80 81 |
# File 'lib/artirix_data_models/aggregation.rb', line 79 def aggregation_name @aggregation_name end |
#aggregations ⇒ Object Also known as: nested_aggregations
89 90 91 |
# File 'lib/artirix_data_models/aggregation.rb', line 89 def aggregations Array(@aggregations) end |
#count ⇒ Object
Returns the value of attribute count.
79 80 81 |
# File 'lib/artirix_data_models/aggregation.rb', line 79 def count @count end |
#filtered ⇒ Object
Returns the value of attribute filtered.
79 80 81 |
# File 'lib/artirix_data_models/aggregation.rb', line 79 def filtered @filtered end |
#name ⇒ Object
Returns the value of attribute name.
79 80 81 |
# File 'lib/artirix_data_models/aggregation.rb', line 79 def name @name end |
Instance Method Details
#aggregation(name) ⇒ Object
108 109 110 111 |
# File 'lib/artirix_data_models/aggregation.rb', line 108 def aggregation(name) n = name.to_sym aggregations.detect { |x| x.name == n } end |
#basic_data_hash ⇒ Object
121 122 123 124 125 126 |
# File 'lib/artirix_data_models/aggregation.rb', line 121 def basic_data_hash { name: name, count: count } end |
#data_hash ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/artirix_data_models/aggregation.rb', line 113 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
100 101 102 |
# File 'lib/artirix_data_models/aggregation.rb', line 100 def default_pretty_name name end |
#empty? ⇒ Boolean
104 105 106 |
# File 'lib/artirix_data_models/aggregation.rb', line 104 def empty? count == 0 end |
#filtered? ⇒ Boolean
136 137 138 |
# File 'lib/artirix_data_models/aggregation.rb', line 136 def filtered? !!@filtered end |
#mark_filtered ⇒ Object
128 129 130 |
# File 'lib/artirix_data_models/aggregation.rb', line 128 def mark_filtered @filtered = true end |
#mark_unfiltered ⇒ Object
132 133 134 |
# File 'lib/artirix_data_models/aggregation.rb', line 132 def mark_unfiltered @filtered = false end |
#pretty_name ⇒ Object
96 97 98 |
# File 'lib/artirix_data_models/aggregation.rb', line 96 def pretty_name @pretty_name ||= load_pretty_name end |