Skip to content

Commit 19efe1e

Browse files
committed
Correct CSV option and recipe documentation
1 parent 0873ab3 commit 19efe1e

6 files changed

Lines changed: 19 additions & 16 deletions

File tree

‎doc/csv/options/common/quote_char.rdoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
====== Option +quote_char+
22

3-
Specifies the character (\String of length 1) used used to quote fields
3+
Specifies the character (\String of length 1) used to quote fields
44
in both parsing and generating.
55
This String will be transcoded into the data's \Encoding before use.
66

‎doc/csv/options/generating/write_headers.rdoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Without +write_headers+:
1717
csv.shift
1818
end # => ["foo", "0"]
1919

20-
With +write_headers+":
20+
With +write_headers+:
2121
CSV.open(file_path,'w',
2222
:write_headers => true,
2323
:headers => ['Name','Value']

‎doc/csv/options/parsing/headers.rdoc‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ the first row of the data is treated as a row of headers:
3131
bax,2
3232
EOT
3333
csv = CSV.new(str, headers: true)
34-
csv # => #<CSV io_type:StringIO encoding:UTF-8 lineno:2 col_sep:"," row_sep:"\n" quote_char:"\"" headers:["Name", "Count"]>
34+
csv # => #<CSV io_type:StringIO encoding:UTF-8 lineno:0 col_sep:"," row_sep:"\n" quote_char:"\"" headers:true>
35+
csv.headers # => true
36+
csv.shift # => #<CSV::Row "Name":"foo" "Count":"0">
3537
csv.headers # => ["Name", "Count"]
36-
csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
3738

3839
---
3940

@@ -46,7 +47,7 @@ If set to an \Array, the \Array elements are treated as headers:
4647
csv = CSV.new(str, headers: ['Name', 'Count'])
4748
csv
4849
csv.headers # => ["Name", "Count"]
49-
csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
50+
csv.shift # => #<CSV::Row "Name":"foo" "Count":"0">
5051

5152
---
5253

@@ -60,4 +61,4 @@ with the current +options+, and the returned \Array is treated as headers:
6061
csv = CSV.new(str, headers: 'Name,Count')
6162
csv
6263
csv.headers # => ["Name", "Count"]
63-
csv.shift # => #<CSV::Row "Name":"bar" "Count":"1">
64+
csv.shift # => #<CSV::Row "Name":"foo" "Count":"0">

‎doc/csv/options/parsing/skip_blanks.rdoc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ a line that contains a column separator is not considered to be blank.
66
Default value:
77
CSV::DEFAULT_OPTIONS.fetch(:skip_blanks) # => false
88

9-
See also option {skiplines}[#class-CSV-label-Option+skip_lines].
9+
See also option {skip_lines}[#class-CSV-label-Option+skip_lines].
1010

1111
For examples in this section:
1212
str = <<-EOT

‎doc/csv/options/parsing/skip_lines.rdoc‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
Specifies an object to use in identifying comment lines in the input that are to be ignored:
44
* If a \Regexp, ignores lines that match it.
5-
* If a \String, converts it to a \Regexp, ignores lines that match it.
5+
* If a \String, ignores lines that include it.
66
* If +nil+, no lines are considered to be comments.
7+
* Otherwise, the object must respond to +match+; ignores lines for which +match+ returns a truthy value.
78

89
Default value:
910
CSV::DEFAULT_OPTIONS.fetch(:skip_lines) # => nil
@@ -32,6 +33,7 @@ Using a \String:
3233

3334
---
3435

35-
Raises an exception if given an object that is not a \Regexp, a \String, or +nil+:
36+
Raises an exception if given an object that is not a \Regexp, a \String, +nil+,
37+
or an object that responds to +match+:
3638
# Raises ArgumentError (:skip_lines has to respond to #match: 0)
3739
CSV.parse(str, skip_lines: 0)

‎doc/csv/recipes/generating.rdoc‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All code snippets on this page assume that the following has been executed:
1616
- {Generating to a File}[#label-Generating+to+a+File]
1717
- {Recipe: Generate to File with Headers}[#label-Recipe-3A+Generate+to+File+with+Headers]
1818
- {Recipe: Generate to File Without Headers}[#label-Recipe-3A+Generate+to+File+Without+Headers]
19-
- {Generating to IO an Stream}[#label-Generating+to+an+IO+Stream]
19+
- {Generating to an IO Stream}[#label-Generating+to+an+IO+Stream]
2020
- {Recipe: Generate to IO Stream with Headers}[#label-Recipe-3A+Generate+to+IO+Stream+with+Headers]
2121
- {Recipe: Generate to IO Stream Without Headers}[#label-Recipe-3A+Generate+to+IO+Stream+Without+Headers]
2222
- {Converting Fields}[#label-Converting+Fields]
@@ -71,11 +71,11 @@ that are to be generated:
7171

7272
==== Generating to a \File
7373

74-
You can generate /CSV data to a \File, with or without headers.
74+
You can generate \CSV data to a \File, with or without headers.
7575

7676
===== Recipe: Generate to \File with Headers
7777

78-
Use class method CSV.open with option +headers+ generate to a \File.
78+
Use class method CSV.open with option +headers+ to generate to a \File.
7979

8080
This example uses method CSV#<< to append the rows
8181
that are to be generated:
@@ -105,7 +105,7 @@ that are to be generated:
105105

106106
You can generate \CSV data to an \IO stream, with or without headers.
107107

108-
==== Recipe: Generate to \IO Stream with Headers
108+
===== Recipe: Generate to \IO Stream with Headers
109109

110110
Use class method CSV.new with option +headers+ to generate \CSV data to an \IO stream:
111111
path = 't.csv'
@@ -187,7 +187,7 @@ For strict compliance, use option +:row_sep+ to specify row separator <tt>"\r\n"
187187
===== Recipe: Generate Non-Compliant Row Separator
188188

189189
For data with non-compliant row separators, use option +:row_sep+ with a different value:
190-
This example source uses semicolon (<tt>";'</tt>) as its row separator:
190+
This example source uses semicolon (<tt>";"</tt>) as its row separator:
191191
output_string = CSV.generate('', row_sep: ";") do |csv|
192192
csv << ['Foo', 0]
193193
csv << ['Bar', 1]
@@ -223,11 +223,11 @@ This example source uses TAB (<tt>"\t"</tt>) as its column separator:
223223

224224
==== Quotes
225225

226-
IFC 4180 allows most fields to be quoted or not.
226+
RFC 4180 allows most fields to be quoted or not.
227227
By default, \CSV does not quote most fields.
228228

229229
However, a field containing the current row separator, column separator,
230-
or quote character is automatically quoted, producing IFC 4180 compliance:
230+
or quote character is automatically quoted, producing RFC 4180 compliance:
231231
# Field contains row separator.
232232
output_string = CSV.generate('') do |csv|
233233
row_sep = csv.row_sep

0 commit comments

Comments
 (0)