Class: AjLisp::StringSource
- Inherits:
-
Object
- Object
- AjLisp::StringSource
- Defined in:
- lib/ajlisp/string_source.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(text) ⇒ StringSource
constructor
A new instance of StringSource.
- #nextChar ⇒ Object
- #pushChar(ch) ⇒ Object
Constructor Details
#initialize(text) ⇒ StringSource
Returns a new instance of StringSource.
5 6 7 8 9 |
# File 'lib/ajlisp/string_source.rb', line 5 def initialize(text) @text = text @position = 0 @chars = [] end |
Instance Method Details
#nextChar ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ajlisp/string_source.rb', line 11 def nextChar char = @chars.pop if char return char end char = @text[@position] @position += 1 return char end |
#pushChar(ch) ⇒ Object
23 24 25 |
# File 'lib/ajlisp/string_source.rb', line 23 def pushChar(ch) @chars.push ch end |