Class: Nendo::CharReader
- Inherits:
-
Object
- Object
- Nendo::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.
271 272 273 274 275 |
# File 'lib/nendo.rb', line 271 def initialize( inport, sourcefile ) @inport = inport @sourcefile = sourcefile self.reset end |
Instance Method Details
#column ⇒ Object
309 310 311 |
# File 'lib/nendo.rb', line 309 def column @column end |
#getc ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/nendo.rb', line 282 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
305 306 307 |
# File 'lib/nendo.rb', line 305 def lineno @lineno end |
#reset ⇒ Object
277 278 279 280 |
# File 'lib/nendo.rb', line 277 def reset @lineno = 1 @column = 1 end |
#sourcefile ⇒ Object
301 302 303 |
# File 'lib/nendo.rb', line 301 def sourcefile @sourcefile end |
#ungetc(ch) ⇒ Object
295 296 297 298 299 |
# File 'lib/nendo.rb', line 295 def ungetc( ch ) @lineno = @undo_lineno @column = @undo_column @inport.ungetc( ch ) end |