Class: RediSearch::Aggregate::Reducers::Quantile

Inherits:
RediSearch::ApplicationClause show all
Defined in:
lib/redi_search/aggregate/reducers/quantile.rb

Instance Method Summary collapse

Methods inherited from RediSearch::ApplicationClause

#clause_order, clause_order, clause_term

Methods included from Validatable

included, #validate!

Constructor Details

#initialize(property:, quantile:, as:) ⇒ Quantile



13
14
15
16
17
18
# File 'lib/redi_search/aggregate/reducers/quantile.rb', line 13

def initialize(property:, quantile:, as:)
  @property = property.to_s
  @property.prepend("@") unless @property.start_with?("@")
  @quantile = quantile
  @as = as
end

Instance Method Details

#clauseObject



20
21
22
23
24
25
26
# File 'lib/redi_search/aggregate/reducers/quantile.rb', line 20

def clause
  validate!

  command =  ["REDUCE", "QUANTILE", 2, property, quantile]
  command += ["AS", as] if as
  command
end