Class: BitClust::LineStream

Inherits:
Object show all
Defined in:
lib/bitclust/parseutils.rb

Overview

Provides line-wise access to a file with :file and :line. Used by Preprocessor

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ LineStream

Returns a new instance of LineStream.


21
22
23
# File 'lib/bitclust/parseutils.rb', line 21

def initialize(f)
  @f = f
end

Instance Method Details

#getsObject


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bitclust/parseutils.rb', line 25

def gets
  line = @f.gets
  return nil unless line
  if @f.respond_to?(:path)
    path = @f.path
  else
    path = nil
  end
  line.location = Location.new(path, @f.lineno)
  line
end