Class: Qiita::Elasticsearch::Nodes::QueryNode

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita/elasticsearch/nodes/query_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(tokens) ⇒ QueryNode

Returns a new instance of QueryNode.

Parameters:

  • tokens (Array<Qiita::Elasticsearch::Tokens>)


9
10
11
# File 'lib/qiita/elasticsearch/nodes/query_node.rb', line 9

def initialize(tokens)
  @tokens = tokens
end

Instance Method Details

#to_hashObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/qiita/elasticsearch/nodes/query_node.rb', line 13

def to_hash
  case @tokens.length
  when 0
    {}
  when 1
    MatchNode.new(@tokens.first).to_hash
  else
    MultiMustNode.new(@tokens).to_hash
  end
end