Class: PuppetDBQuery::Parser
- Inherits:
-
Object
- Object
- PuppetDBQuery::Parser
- Includes:
- Logging
- Defined in:
- lib/puppetdb_query/parser.rb
Overview
parse a puppetdb query string into #PuppetDBQuery::Term s
Constant Summary collapse
- AND =
these are the operators we understand rubocop:disable Style/ExtraSpacing
Operator.new(:and, true, 100, 2)
- OR =
Operator.new(:or, true, 90, 2)
- NOT =
Operator.new(:not, false, 1, 1, 1)
- EQUAL =
Operator.new(:equal, true, 200, 2, 2)
- NOT_EQUAL =
Operator.new(:not_equal, true, 200, 2, 2)
- MATCH =
Operator.new(:match, true, 200, 2, 2)
- OPERATORS =
map certain symbols (we get them from a tokenizer) to our operators
{ AND.symbol => AND, OR.symbol => OR, NOT.symbol => NOT, EQUAL.symbol => EQUAL, NOT_EQUAL.symbol => NOT_EQUAL, MATCH.symbol => MATCH, }.freeze
Instance Attribute Summary collapse
-
#position ⇒ Object
readonly
current parsing position in array of symbols.
-
#symbols ⇒ Object
readonly
array of symbols.
Class Method Summary collapse
Instance Method Summary collapse
-
#parse(query) ⇒ Object
parse query and get resulting array of PuppetDBQuery::Term s.
Methods included from Logging
Instance Attribute Details
#position ⇒ Object (readonly)
current parsing position in array of symbols
36 37 38 |
# File 'lib/puppetdb_query/parser.rb', line 36 def position @position end |
#symbols ⇒ Object (readonly)
array of symbols
35 36 37 |
# File 'lib/puppetdb_query/parser.rb', line 35 def symbols @symbols end |
Class Method Details
.parse(puppetdb_query) ⇒ Object
11 12 13 |
# File 'lib/puppetdb_query/parser.rb', line 11 def self.parse(puppetdb_query) Parser.new.parse(puppetdb_query) end |