Sha256: 108b2970689a4edd493308662bb7cec0504f12a508adf68ed82a1902fe2b9624

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

require "csv"

module ReciteCSV
  module Reader
    module Core
      include Enumerable

      attr_reader :file, :csv_options

      def initialize(file, csv_options = {})
        @file = file
        @csv_options = (csv_options || {}).merge(self.class::DEFAULT_CSV_OPIONS)
      end

      def each
        if block_given?
          ::CSV.foreach(self.file, self.csv_options) do |raw_row|
            yield self.class::Row.new(raw_row)
          end
        else
          self.to_enum
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
recite_csv-0.1.0 lib/recite_csv/reader/core.rb