Class: Elastic::Results::Aggregations
- Includes:
- Enumerable
- Defined in:
- lib/elastic/results/aggregations.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #[](_key) ⇒ Object
- #as_value ⇒ Object
- #each(&_block) ⇒ Object
-
#initialize(_aggs) ⇒ Aggregations
constructor
A new instance of Aggregations.
- #traverse(&_block) ⇒ Object
Methods included from Support::Traversable
Constructor Details
#initialize(_aggs) ⇒ Aggregations
Returns a new instance of Aggregations.
7 8 9 |
# File 'lib/elastic/results/aggregations.rb', line 7 def initialize(_aggs) @aggs = _aggs end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/elastic/results/aggregations.rb', line 5 def key @key end |
Instance Method Details
#[](_key) ⇒ Object
11 12 13 |
# File 'lib/elastic/results/aggregations.rb', line 11 def [](_key) @aggs[_key.to_sym].try(:as_value) end |
#as_value ⇒ Object
19 20 21 22 |
# File 'lib/elastic/results/aggregations.rb', line 19 def as_value # TODO: return aggregation value if configured as single bucket self end |
#each(&_block) ⇒ Object
15 16 17 |
# File 'lib/elastic/results/aggregations.rb', line 15 def each(&_block) @aggs.each(&_block) end |
#traverse(&_block) ⇒ Object
24 25 26 27 |
# File 'lib/elastic/results/aggregations.rb', line 24 def traverse(&_block) super @aggs.each_value { |a| a.traverse(&_block) } end |