Skip to content

Instantly share code, notes, and snippets.

@gosukiwi
Created June 8, 2017 18:52
Show Gist options
  • Save gosukiwi/eebfa98f7b548ed5a966972bd2ccc983 to your computer and use it in GitHub Desktop.
Save gosukiwi/eebfa98f7b548ed5a966972bd2ccc983 to your computer and use it in GitHub Desktop.
class SimpleScanner
TOKEN_TYPES = {
'_' => 'UNDERSCORE',
'*' => 'STAR',
"\n" => 'NEWLINE'
}.freeze
def self.from_string(plain_markdown)
char = plain_markdown[0]
Token.new(type: TOKEN_TYPES[char], value: char)
rescue InvalidTokenError
Token.null
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment