Class: Memoir::Query
- Inherits:
-
Object
- Object
- Memoir::Query
- Defined in:
- lib/memoir/query.rb
Instance Attribute Summary collapse
-
#aggregator ⇒ Object
Returns the value of attribute aggregator.
-
#downsample ⇒ Object
Returns the value of attribute downsample.
-
#explicit_tags ⇒ Object
Returns the value of attribute explicit_tags.
-
#filters ⇒ Object
Returns the value of attribute filters.
-
#metric ⇒ Object
Returns the value of attribute metric.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#rate_options ⇒ Object
Returns the value of attribute rate_options.
Instance Method Summary collapse
- #<<(filter) ⇒ Object
- #add_filter(filter) ⇒ Object
- #clear_filters ⇒ Object
-
#initialize(aggregator, metric, downsample = nil, explicit_tags = false, rate = false, rate_options = {}) ⇒ Query
constructor
A new instance of Query.
- #remove_filter(filter) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(aggregator, metric, downsample = nil, explicit_tags = false, rate = false, rate_options = {}) ⇒ Query
Returns a new instance of Query.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/memoir/query.rb', line 4 def initialize(aggregator, metric, downsample = nil, = false, rate = false, = {}) @aggregator = aggregator @metric = metric @downsample = downsample @rate = rate @rate_options = @tags = {} @filters = [] @explicit_tags = end |
Instance Attribute Details
#aggregator ⇒ Object
Returns the value of attribute aggregator.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def aggregator @aggregator end |
#downsample ⇒ Object
Returns the value of attribute downsample.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def downsample @downsample end |
#explicit_tags ⇒ Object
Returns the value of attribute explicit_tags.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def @explicit_tags end |
#filters ⇒ Object
Returns the value of attribute filters.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def filters @filters end |
#metric ⇒ Object
Returns the value of attribute metric.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def metric @metric end |
#rate ⇒ Object
Returns the value of attribute rate.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def rate @rate end |
#rate_options ⇒ Object
Returns the value of attribute rate_options.
2 3 4 |
# File 'lib/memoir/query.rb', line 2 def @rate_options end |
Instance Method Details
#<<(filter) ⇒ Object
15 16 17 |
# File 'lib/memoir/query.rb', line 15 def <<(filter) add_filter(filter) end |
#add_filter(filter) ⇒ Object
19 20 21 |
# File 'lib/memoir/query.rb', line 19 def add_filter(filter) filters << filter end |
#clear_filters ⇒ Object
27 28 29 |
# File 'lib/memoir/query.rb', line 27 def clear_filters filters.clear end |
#remove_filter(filter) ⇒ Object
23 24 25 |
# File 'lib/memoir/query.rb', line 23 def remove_filter(filter) filters.delete filter end |
#to_h ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/memoir/query.rb', line 31 def to_h hash = { 'aggregator' => aggregator, 'metric' => metric, 'rate' => rate, 'explicitTags' => } hash['rateOptions'] = unless .empty? hash['downsample'] = downsample.to_s if downsample hash['filters'] = filters.map(&:to_h) unless filters.empty? hash end |