Class: Druid::PostAggregationOperation
- Inherits:
-
Object
- Object
- Druid::PostAggregationOperation
- Includes:
- PostAggregationOperators
- Defined in:
- lib/druid/post_aggregation.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #as(field) ⇒ Object
- #as_json(*a) ⇒ Object
- #get_field_names ⇒ Object
-
#initialize(left, operator, right) ⇒ PostAggregationOperation
constructor
A new instance of PostAggregationOperation.
- #to_hash ⇒ Object
- #to_json(*a) ⇒ Object
Methods included from PostAggregationOperators
Constructor Details
#initialize(left, operator, right) ⇒ PostAggregationOperation
Returns a new instance of PostAggregationOperation.
41 42 43 44 45 |
# File 'lib/druid/post_aggregation.rb', line 41 def initialize(left, operator, right) @left = left.is_a?(Numeric) ? PostAggregationConstant.new(left) : left @operator = operator @right = right.is_a?(Numeric) ? PostAggregationConstant.new(right) : right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
39 40 41 |
# File 'lib/druid/post_aggregation.rb', line 39 def left @left end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/druid/post_aggregation.rb', line 39 def name @name end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
39 40 41 |
# File 'lib/druid/post_aggregation.rb', line 39 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
39 40 41 |
# File 'lib/druid/post_aggregation.rb', line 39 def right @right end |
Instance Method Details
#as(field) ⇒ Object
47 48 49 50 |
# File 'lib/druid/post_aggregation.rb', line 47 def as(field) @name = field.name.to_s self end |
#as_json(*a) ⇒ Object
69 70 71 |
# File 'lib/druid/post_aggregation.rb', line 69 def as_json(*a) to_hash end |
#get_field_names ⇒ Object
52 53 54 55 56 57 |
# File 'lib/druid/post_aggregation.rb', line 52 def get_field_names field_names = [] field_names << left.get_field_names if left.respond_to?(:get_field_names) field_names << right.get_field_names if right.respond_to?(:get_field_names) field_names end |
#to_hash ⇒ Object
59 60 61 62 63 |
# File 'lib/druid/post_aggregation.rb', line 59 def to_hash hash = { "type" => "arithmetic", "fn" => @operator, "fields" => [@left.to_hash, @right.to_hash] } hash["name"] = @name if @name hash end |
#to_json(*a) ⇒ Object
65 66 67 |
# File 'lib/druid/post_aggregation.rb', line 65 def to_json(*a) to_hash.to_json(*a) end |