summaryrefslogtreecommitdiff
path: root/doc/csv/write_headers.rdoc
diff options
context:
space:
mode:
authorBurdette Lamar <BurdetteLamar@Yahoo.com>2020-05-12 16:42:45 -0500
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-07-20 02:32:50 +0900
commit6ba1abd40c4610506a638246431660a32a9b1798 (patch)
treeb680025fca57f8aa0e1cece9cb7568d53af91400 /doc/csv/write_headers.rdoc
parent033514c62fef937dda904daa3b73b2b9750913f0 (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.rdoc29
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"]