Class: CharReader
- Inherits:
-
Object
- Object
- CharReader
- Defined in:
- lib/nendo.rb
Instance Method Summary collapse
- #column ⇒ Object
- #getc ⇒ Object
-
#initialize(inport, sourcefile) ⇒ CharReader
constructor
A new instance of CharReader.
- #lineno ⇒ Object
- #reset ⇒ Object
- #sourcefile ⇒ Object
- #ungetc(ch) ⇒ Object
Constructor Details
#initialize(inport, sourcefile) ⇒ CharReader
Returns a new instance of CharReader.
136 137 138 139 140 |
# File 'lib/nendo.rb', line 136 def initialize( inport, sourcefile ) @inport = inport @sourcefile = sourcefile self.reset end |
Instance Method Details
#column ⇒ Object
174 175 176 |
# File 'lib/nendo.rb', line 174 def column @column end |
#getc ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/nendo.rb', line 147 def getc @undo_lineno = @lineno @undo_column = @column ch = @inport.getc if nil != ch if ch.chr.match( /[\r\n]/ ) @lineno += 1 end @column += 1 end ch end |
#lineno ⇒ Object
170 171 172 |
# File 'lib/nendo.rb', line 170 def lineno @lineno end |
#reset ⇒ Object
142 143 144 145 |
# File 'lib/nendo.rb', line 142 def reset @lineno = 1 @column = 1 end |
#sourcefile ⇒ Object
166 167 168 |
# File 'lib/nendo.rb', line 166 def sourcefile @sourcefile end |
#ungetc(ch) ⇒ Object
160 161 162 163 164 |
# File 'lib/nendo.rb', line 160 def ungetc( ch ) @lineno = @undo_lineno @column = @undo_column @inport.ungetc( ch ) end |