class TwitterCldr::Parsers::Parser
base class, not meant to be instantiated
Public Instance Methods
eof?()
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 24 def eof? @token_index >= @tokens.size end
parse(tokens, options = {})
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 14 def parse(tokens, options = {}) @tokens = tokens reset do_parse(options) end
reset()
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 20 def reset @token_index = 0 end
Private Instance Methods
current_token()
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 48 def current_token @tokens[@token_index] end
empty?(token)
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 44 def empty?(token) token.type == :plaintext && token.value == "" end
next_token(type)
click to toggle source
# File lib/twitter_cldr/parsers/parser.rb, line 30 def next_token(type) unless current_token.type == type raise UnexpectedTokenError.new("Unexpected token #{current_token.type} \"#{current_token.value}\"") end @token_index += 1 while current_token && empty?(current_token) @token_index += 1 end current_token end