Sha256: d1294ea478cca8b5a263c83f4306f52111ae427e1ce9e30ce27a951b6f1ffb48

Contents?: true

Size: 680 Bytes

Versions: 8

Compression:

Stored size: 680 Bytes

Contents

module Alf
  class Reader
    #
    # Implements Alf::Reader contract for reading CSV files.
    #
    class CSV < Reader
      include Support::CSVUtils

      def self.mime_type
        "text/csv"
      end

      def each
        return to_enum unless block_given?
        with_input_io do |io|
          block = Proc.new{|row|
            next if row.header_row?
            yield(::Alf::Support.symbolize_keys(row.to_hash))
          }
          csv_input = io.is_a?(StringIO) ? io.string : io
          get_csv(csv_input, options).each(&block)
        end
      end

      Alf::Reader.register(:csv, [".csv"], self)
    end # class CSV
  end # class Reader
end # module Alf

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/reader/csv.rb
alf-core-0.16.2 lib/alf/reader/csv.rb
alf-core-0.16.1 lib/alf/reader/csv.rb
alf-core-0.16.0 lib/alf/reader/csv.rb
alf-core-0.15.0 lib/alf/reader/csv.rb
alf-core-0.14.0 lib/alf-io/alf/reader/csv.rb
alf-core-0.13.1 lib/alf-io/alf/reader/csv.rb
alf-core-0.13.0 lib/alf-io/alf/reader/csv.rb