Class: Nendo::CharReader
- Inherits:
-
Object
- Object
- Nendo::CharReader
- Defined in:
- lib/nendo/ruby/reader.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.
38 39 40 41 42 |
# File 'lib/nendo/ruby/reader.rb', line 38 def initialize( inport, sourcefile ) @inport = inport @sourcefile = sourcefile self.reset end |
Instance Method Details
#column ⇒ Object
76 77 78 |
# File 'lib/nendo/ruby/reader.rb', line 76 def column @column end |
#getc ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nendo/ruby/reader.rb', line 49 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
72 73 74 |
# File 'lib/nendo/ruby/reader.rb', line 72 def lineno @lineno end |
#reset ⇒ Object
44 45 46 47 |
# File 'lib/nendo/ruby/reader.rb', line 44 def reset @lineno = 1 @column = 1 end |
#sourcefile ⇒ Object
68 69 70 |
# File 'lib/nendo/ruby/reader.rb', line 68 def sourcefile @sourcefile end |
#ungetc(ch) ⇒ Object
62 63 64 65 66 |
# File 'lib/nendo/ruby/reader.rb', line 62 def ungetc( ch ) @lineno = @undo_lineno @column = @undo_column @inport.ungetc( ch ) end |