Module: Gorillib::Model::LoadLines::ClassMethods

Defined in:
lib/gorillib/model/serialization/lines.rb

Instance Method Summary collapse

Instance Method Details

#_each_raw_line(filename, options = {}) { ... } ⇒ Object

Iterate a block over each line of a file

Yields:

  • each line in the file.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gorillib/model/serialization/lines.rb', line 13

def _each_raw_line(filename, options={})
  filename = Pathname.path_to(filename)
  #
  pop_headers = options.delete(:pop_headers)
  #
  File.open(filename) do |file|
    file.readline if pop_headers
    file.each do |line|
      line.chomp! ; next if line.empty?
      yield line
    end
    nil
  end
end