Sha256: 24111754f09f23fa500c6e0e4e2a496210b3b8a9ce6ce4779006739d29dcc487

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

require 'gorillib/pathname'

module Gorillib
  module Model

    module LoadLines
      extend Gorillib::Concern

      module ClassMethods

        # Iterate a block over each line of a file
        # @yield each line in the file.
        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

      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gorillib-0.6.0 lib/gorillib/model/serialization/lines.rb
gorillib-0.5.2 lib/gorillib/model/serialization/lines.rb