class Tickethub::Aggregate

Public Class Methods

new(collection, group) click to toggle source
# File lib/tickethub/aggregate.rb, line 4
def initialize(collection, group)
  @group = Array group.dup
  @collection = collection
end

Public Instance Methods

average(field) click to toggle source
# File lib/tickethub/aggregate.rb, line 21
def average(field)
  @collection.get aggregate: { field: field, group: @group, operation: 'average' }
end
Also aliased as: avg
avg(field)
Alias for: average
count(field = :id) click to toggle source
# File lib/tickethub/aggregate.rb, line 31
def count(field = :id)
  @collection.get aggregate: { field: field, group: @group, operation: 'count' }
end
max(field)
Alias for: maximum
maximum(field) click to toggle source
# File lib/tickethub/aggregate.rb, line 15
def maximum(field)
  @collection.get aggregate: { field: field, group: @group, operation: 'maximum' }
end
Also aliased as: max
min(field)
Alias for: minimum
minimum(field) click to toggle source
# File lib/tickethub/aggregate.rb, line 9
def minimum(field)
  @collection.get aggregate: { field: field, group: @group, operation: 'minimum' }
end
Also aliased as: min
sum(field) click to toggle source
# File lib/tickethub/aggregate.rb, line 27
def sum(field)
  @collection.get aggregate: { field: field, group: @group, operation: 'sum' }
end