Class: Alf::Reader::CSV
- Inherits:
-
Alf::Reader
- Object
- Alf::Reader
- Alf::Reader::CSV
- Includes:
- Support::CSVUtils
- Defined in:
- lib/alf-io/alf/reader/csv.rb
Overview
Implements Alf::Reader contract for reading CSV files.
Constant Summary
Constants included from Support::CSVUtils
Support::CSVUtils::DEFAULT_OPTIONS
Constants inherited from Alf::Reader
Instance Attribute Summary
Attributes inherited from Alf::Reader
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Alf::Reader
by_mime_type, coerce, #initialize, reader, register
Methods included from Support::Registry
#listen, #listeners, #register, #registered
Methods included from Engine::Cog
Constructor Details
This class inherits a constructor from Alf::Reader
Class Method Details
.mime_type ⇒ Object
9 10 11 |
# File 'lib/alf-io/alf/reader/csv.rb', line 9 def self.mime_type "text/csv" end |
Instance Method Details
#each ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/alf-io/alf/reader/csv.rb', line 13 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, ).each(&block) end end |