Class: GmailSearchSyntax::Parser
- Inherits:
-
Object
- Object
- GmailSearchSyntax::Parser
- Defined in:
- lib/gmail_search_syntax/parser.rb
Constant Summary collapse
- OPERATORS =
%w[ from to cc bcc subject after before older newer older_than newer_than label category has list filename in is deliveredto size larger smaller rfc822msgid ].freeze
Instance Method Summary collapse
-
#initialize(tokens) ⇒ Parser
constructor
A new instance of Parser.
- #parse! ⇒ Object
Constructor Details
#initialize(tokens) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 |
# File 'lib/gmail_search_syntax/parser.rb', line 9 def initialize(tokens) @tokens = tokens @position = 0 end |
Instance Method Details
#parse! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gmail_search_syntax/parser.rb', line 14 def parse! children = [] until eof? node = parse_expression children << node if node end if children.empty? raise GmailSearchSyntax::EmptyQueryError, "Query cannot be empty" end children.first end |