Class: EverSdk::Net::FieldAggregation

Inherits:
Object
  • Object
show all
Defined in:
lib/ever_sdk_client/net.rb

Constant Summary collapse

AGGREGATION_FN_VALUES =
[
  :count,
  :min,
  :max,
  :sum,
  :average
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, fn:) ⇒ FieldAggregation

Returns a new instance of FieldAggregation.



157
158
159
160
161
162
163
# File 'lib/ever_sdk_client/net.rb', line 157

def initialize(field:, fn:)
  unless AGGREGATION_FN_VALUES.include?(fn)
    raise ArgumentError.new("aggregate function #{fn} doesn't exist; existing values: #{AGGREGATION_FN_VALUES}")
  end
  @field = field
  @fn = fn
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



155
156
157
# File 'lib/ever_sdk_client/net.rb', line 155

def field
  @field
end

#fnObject (readonly)

Returns the value of attribute fn.



155
156
157
# File 'lib/ever_sdk_client/net.rb', line 155

def fn
  @fn
end

Instance Method Details

#to_hObject



165
166
167
168
169
170
# File 'lib/ever_sdk_client/net.rb', line 165

def to_h
  {
    field: @field,
    fn: @fn.to_s.upcase
  }
end