Module: Dynomite::Item::Query::Relation::Math

Included in:
Dynomite::Item::Query::Relation
Defined in:
lib/dynomite/item/query/relation/math.rb

Instance Method Summary collapse

Instance Method Details

#average(field) ⇒ Object



3
4
5
# File 'lib/dynomite/item/query/relation/math.rb', line 3

def average(field)
  map(&field).sum.to_f / count
end

#max(field) ⇒ Object



11
12
13
# File 'lib/dynomite/item/query/relation/math.rb', line 11

def max(field)
  map(&field).max
end

#min(field) ⇒ Object



7
8
9
# File 'lib/dynomite/item/query/relation/math.rb', line 7

def min(field)
  map(&field).min
end

#sum(field) ⇒ Object



15
16
17
# File 'lib/dynomite/item/query/relation/math.rb', line 15

def sum(field)
  map(&field).sum
end