Class: ScratchLexer
- Inherits:
-
Object
- Object
- ScratchLexer
- Defined in:
- lib/lem.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(text) ⇒ ScratchLexer
constructor
A new instance of ScratchLexer.
- #next_word ⇒ Object
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
#each ⇒ Object
19 20 21 |
# File 'lib/lem.rb', line 19 def each @words.each { |word| yield word } end |
#next_word ⇒ Object
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 |