Class: ScratchLexer

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

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ ScratchLexer

Returns a new instance of ScratchLexer.



8
9
10
11
# File 'lib/lem.rb', line 8

def initialize(text)
	@words = text.split(/\s+/)
	@next = 0
end

Instance Method Details

#eachObject



19
20
21
# File 'lib/lem.rb', line 19

def each
	@words.each { |word| yield word }
end

#next_wordObject



13
14
15
16
17
# File 'lib/lem.rb', line 13

def next_word
	return nil if @next >= @words.length 
	@next += 1
	@words[@next-1] 
end