Class: StrongCSV
- Inherits:
-
Object
- Object
- StrongCSV
- Defined in:
- lib/strong_csv.rb,
lib/strong_csv/let.rb,
lib/strong_csv/row.rb,
lib/strong_csv/version.rb,
lib/strong_csv/types/base.rb,
lib/strong_csv/types/time.rb,
lib/strong_csv/types/float.rb,
lib/strong_csv/types/union.rb,
lib/strong_csv/type_wrapper.rb,
lib/strong_csv/types/string.rb,
lib/strong_csv/value_result.rb,
lib/strong_csv/types/boolean.rb,
lib/strong_csv/types/integer.rb,
lib/strong_csv/types/literal.rb,
lib/strong_csv/types/optional.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Modules: Types Classes: Error, Let, Row, TypeWrapper, ValueResult
Constant Summary collapse
- VERSION =
"0.8.4"
Instance Method Summary collapse
-
#initialize(&block) ⇒ StrongCSV
constructor
A new instance of StrongCSV.
- #parse(csv, **options) ⇒ Object
Constructor Details
Instance Method Details
#parse(csv, **options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/strong_csv.rb', line 49 def parse(csv, **) # NOTE: Some options are overridden here to ensure that StrongCSV can handle parsed values correctly. .delete(:nil_value) = .merge(headers: @let.headers, header_converters: :symbol) csv = CSV.new(csv, **) @let.pickers.each_value do |picker| picker.call(csv) csv.rewind end if block_given? csv.each do |row| yield Row.new(row: row, types: @let.types, lineno: csv.lineno) end else csv.map { |row| Row.new(row: row, types: @let.types, lineno: csv.lineno) } end end |