Class: Pslm::CountingIStream

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/pslm/pslmreader.rb

Overview

wraps an input stream; counts lines read

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#linenoObject (readonly)

Returns the value of attribute lineno.



211
212
213
# File 'lib/pslm/pslmreader.rb', line 211

def lineno
  @lineno
end

Instance Method Details

#getsObject



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

#rewindObject



219
220
221
222
# File 'lib/pslm/pslmreader.rb', line 219

def rewind
  @lineno = 0
  super
end