Class: Cambridge::Tokenizer

Inherits:
Object
  • Object
show all
Defined in:
lib/cambridge/tokenizer.rb

Instance Method Summary collapse

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

#scannerObject



15
16
17
# File 'lib/cambridge/tokenizer.rb', line 15

def scanner
  @scanner ||= Scanner.new
end

#to_rubyObject



7
8
9
# File 'lib/cambridge/tokenizer.rb', line 7

def to_ruby
  tokens.map(&:to_ruby).join("\n")
end

#tokensObject



11
12
13
# File 'lib/cambridge/tokenizer.rb', line 11

def tokens
  @tokens ||= scanner.parse @source
end