mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
920a16893a
commit
d9eff306f5
Notes:
git
2020-07-20 03:35:36 +09:00
23 changed files with 30 additions and 30 deletions
27
doc/csv/options/parsing/unconverted_fields.rdoc
Normal file
27
doc/csv/options/parsing/unconverted_fields.rdoc
Normal file
|
@ -0,0 +1,27 @@
|
|||
====== Option +unconverted_fields+
|
||||
|
||||
Specifies the boolean that determines whether unconverted field values are to be available.
|
||||
|
||||
Default value:
|
||||
CSV::DEFAULT_OPTIONS.fetch(:unconverted_fields) # => nil
|
||||
|
||||
The unconverted field values are those found in the source data,
|
||||
prior to any conversions performed via option +converters+.
|
||||
|
||||
When option +unconverted_fields+ is +true+,
|
||||
each returned row (\Array or \CSV::Row) has an added method,
|
||||
+unconverted_fields+, that returns the unconverted field values:
|
||||
str = <<-EOT
|
||||
foo,0
|
||||
bar,1
|
||||
baz,2
|
||||
EOT
|
||||
# Without unconverted_fields
|
||||
csv = CSV.parse(str, converters: :integer)
|
||||
csv # => [["foo", 0], ["bar", 1], ["baz", 2]]
|
||||
csv.first.respond_to?(:unconverted_fields) # => false
|
||||
# With unconverted_fields
|
||||
csv = CSV.parse(str, converters: :integer, unconverted_fields: true)
|
||||
csv # => [["foo", 0], ["bar", 1], ["baz", 2]]
|
||||
csv.first.respond_to?(:unconverted_fields) # => true
|
||||
csv.first.unconverted_fields # => ["foo", "0"]
|
Loading…
Add table
Add a link
Reference in a new issue