Class: SearchCop::GrammarParser

Inherits:
Object
  • Object
show all
Defined in:
lib/search_cop/grammar_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_info) ⇒ GrammarParser

Returns a new instance of GrammarParser.



10
11
12
# File 'lib/search_cop/grammar_parser.rb', line 10

def initialize(query_info)
  @query_info = query_info
end

Instance Attribute Details

#query_infoObject (readonly)

Returns the value of attribute query_info.



8
9
10
# File 'lib/search_cop/grammar_parser.rb', line 8

def query_info
  @query_info
end

Instance Method Details

#parse(string, query_options) ⇒ Object



14
15
16
17
18
19
# File 'lib/search_cop/grammar_parser.rb', line 14

def parse(string, query_options)
  node = SearchCopGrammarParser.new.parse(string) || raise(ParseError)
  node.query_info = query_info
  node.query_options = query_options
  node.evaluate
end