Created
June 8, 2017 18:52
-
-
Save gosukiwi/eebfa98f7b548ed5a966972bd2ccc983 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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