Class: Sakuramochi::Condition::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/sakuramochi/condition.rb

Overview

expression = term term term = [“not”] factor factor = array | hash | “(” expression “)”

Constant Summary collapse

EXPRESSIONS =
['and', 'or']
TERMS =
['not']
PARENTHESES =
{'(' => ')'}

Instance Method Summary collapse

Constructor Details

#initialize(tokens) ⇒ Parser

Returns a new instance of Parser.



66
67
68
69
70
# File 'lib/sakuramochi/condition.rb', line 66

def initialize(tokens)
  @tokens = tokens.dup
  @tokens = @tokens.split(/\s+/) if @tokens.is_a?(String) # debug
  @tokens = [@tokens] unless @tokens.is_a?(Array)
end

Instance Method Details

#parseObject



72
73
74
# File 'lib/sakuramochi/condition.rb', line 72

def parse
  expression
end