Class: Cambridge::Tokenizer
- Inherits:
-
Object
- Object
- Cambridge::Tokenizer
- Defined in:
- lib/cambridge/tokenizer.rb
Instance Method Summary collapse
-
#initialize(source) ⇒ Tokenizer
constructor
A new instance of Tokenizer.
- #scanner ⇒ Object
- #to_ruby ⇒ Object
- #tokens ⇒ Object
Constructor Details
#initialize(source) ⇒ Tokenizer
Returns a new instance of Tokenizer.
3 4 5 |
# File 'lib/cambridge/tokenizer.rb', line 3 def initialize(source) @source = source end |
Instance Method Details
#scanner ⇒ Object
15 16 17 |
# File 'lib/cambridge/tokenizer.rb', line 15 def scanner @scanner ||= Scanner.new end |
#to_ruby ⇒ Object
7 8 9 |
# File 'lib/cambridge/tokenizer.rb', line 7 def to_ruby tokens.map(&:to_ruby).join("\n") end |
#tokens ⇒ Object
11 12 13 |
# File 'lib/cambridge/tokenizer.rb', line 11 def tokens @tokens ||= scanner.parse @source end |