Sha256: ac43a161440eb7f0a113a22da4a55cdeb8779314b771feebbdf2776676fd9aac

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

module Gorillib
  module Model

    module LoadLines
      extend ActiveSupport::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.new(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-model-0.0.3 lib/gorillib/model/serialization/lines.rb
gorillib-model-0.0.1 lib/gorillib/model/serialization/lines.rb