Class: Pslm::CountingIStream
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Pslm::CountingIStream
- Defined in:
- lib/pslm/pslmreader.rb
Overview
wraps an input stream; counts lines read
Instance Attribute Summary collapse
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
Instance Method Summary collapse
- #gets ⇒ Object
-
#initialize(stream) ⇒ CountingIStream
constructor
A new instance of CountingIStream.
- #rewind ⇒ Object
Constructor Details
#initialize(stream) ⇒ CountingIStream
Returns a new instance of CountingIStream.
205 206 207 208 209 |
# File 'lib/pslm/pslmreader.rb', line 205 def initialize(stream) super(stream) @stream = stream @lineno = 0 end |
Instance Attribute Details
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
211 212 213 |
# File 'lib/pslm/pslmreader.rb', line 211 def lineno @lineno end |
Instance Method Details
#gets ⇒ Object
213 214 215 216 217 |
# File 'lib/pslm/pslmreader.rb', line 213 def gets l = @stream.gets @lineno += 1 if l != nil return l end |
#rewind ⇒ Object
219 220 221 222 |
# File 'lib/pslm/pslmreader.rb', line 219 def rewind @lineno = 0 super end |