Skip to content

Commit 16b425e

Browse files
doc: fix return value of open {} and use File.open {} (#139)
* Enhanced RDoc for CSV * Repair example code for foreach
1 parent 35392f4 commit 16b425e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/csv.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,10 @@ def filter(input=nil, output=nil, **options)
863863
# ["baz", "2"]
864864
#
865865
# Read rows from an \IO object:
866-
# CSV.foreach(File.open(path)) {|row| p row } # => 21
866+
# File.open(path) do |file|
867+
# CSV.foreach(file) {|row| p row } # => 21
868+
# end
869+
#
867870
# Output:
868871
# ["foo", "0"]
869872
# ["bar", "1"]
@@ -1023,8 +1026,8 @@ def generate_line(row, **options)
10231026
# :call-seq:
10241027
# open(file_path, mode = "rb", **options ) -> new_csv
10251028
# open(io, mode = "rb", **options ) -> new_csv
1026-
# open(file_path, mode = "rb", **options ) { |csv| ... } -> new_csv
1027-
# open(io, mode = "rb", **options ) { |csv| ... } -> new_csv
1029+
# open(file_path, mode = "rb", **options ) { |csv| ... } -> object
1030+
# open(io, mode = "rb", **options ) { |csv| ... } -> object
10281031
#
10291032
# possible options elements:
10301033
# hash form:
@@ -1071,7 +1074,8 @@ def generate_line(row, **options)
10711074
#
10721075
# ---
10731076
#
1074-
# With a block given, calls the block with the created \CSV object:
1077+
# With a block given, calls the block with the created \CSV object;
1078+
# returns the block's return value:
10751079
#
10761080
# Using a file path:
10771081
# csv = CSV.open(path) {|csv| p csv}

0 commit comments

Comments
 (0)