Class: ElasticsearchQueryParser::Grammar::Presenters::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsearch_query_parser/grammar/presenters/operator.rb

Defined Under Namespace

Classes: InvalidOperatorString

Instance Method Summary collapse

Constructor Details

#initialize(operator) ⇒ Operator

Returns a new instance of Operator.



22
23
24
# File 'lib/elasticsearch_query_parser/grammar/presenters/operator.rb', line 22

def initialize(operator)
  @operator = (operator || "OR").to_s.downcase
end

Instance Method Details

#to_elasticsearchObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elasticsearch_query_parser/grammar/presenters/operator.rb', line 26

def to_elasticsearch
  case operator
  when "and"
    :must
  when "not"
    :must_not
  when "or"
    :should
  else
    raise InvalidOperatorString, operator
  end
end