diff options
author | Burdette Lamar <BurdetteLamar@Yahoo.com> | 2020-05-12 16:42:45 -0500 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-07-20 02:32:50 +0900 |
commit | 6ba1abd40c4610506a638246431660a32a9b1798 (patch) | |
tree | b680025fca57f8aa0e1cece9cb7568d53af91400 /doc/csv/write_headers.rdoc | |
parent | 033514c62fef937dda904daa3b73b2b9750913f0 (diff) |
[ruby/csv] Enhanced Rdoc for CSV (#122)
https://github.com/ruby/csv/commit/cd670595d5
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3332
Diffstat (limited to 'doc/csv/write_headers.rdoc')
-rw-r--r-- | doc/csv/write_headers.rdoc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/csv/write_headers.rdoc b/doc/csv/write_headers.rdoc new file mode 100644 index 0000000000..f9faa9d438 --- /dev/null +++ b/doc/csv/write_headers.rdoc @@ -0,0 +1,29 @@ +====== Option +write_headers+ + +Specifies the boolean that determines whether a header row is included in the output; +ignored if there are no headers. + +Default value: + CSV::DEFAULT_OPTIONS.fetch(:write_headers) # => nil + +Without +write_headers+: + file_path = 't.csv' + CSV.open(file_path,'w', + :headers => ['Name','Value'] + ) do |csv| + csv << ['foo', '0'] + end + CSV.open(file_path) do |csv| + csv.shift + end # => ["foo", "0"] + +With +write_headers+": + CSV.open(file_path,'w', + :write_headers=> true, + :headers => ['Name','Value'] + ) do |csv| + csv << ['foo', '0'] + end + CSV.open(file_path) do |csv| + csv.shift + end # => ["Name", "Value"] |