1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/csv.rb: Enhance each() to support Enumerator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
jeg2 2011-05-26 15:35:06 +00:00
parent b74f5dee4a
commit a9c056f1ed
3 changed files with 20 additions and 4 deletions

View file

@ -1,7 +1,11 @@
Thu May 27 00:34:07 2011 James Edward Gray II <jeg2@ruby-lang.org>
* lib/csv.rb: Enhance each() to support Enumerator.
Thu May 26 10:32:11 2011 James Edward Gray II <jeg2@ruby-lang.org>
* lib/csv.rb: Documentation improvements from Ysiad Ferreiras.
[Ruby 1.9 - Bug #4785]
* lib/csv.rb: Documentation improvements from Ysiad Ferreiras.
[Ruby 1.9 - Bug #4785]
Thu May 26 15:42:02 2011 Cezary Baginski <cezary.baginski@gmail.com>

View file

@ -1787,8 +1787,12 @@ class CSV
# The data source must be open for reading.
#
def each
while row = shift
yield row
if block_given?
while row = shift
yield row
end
else
to_enum
end
end

View file

@ -113,6 +113,14 @@ class TestCSV::Interface < TestCSV
end
end
def test_enumerators_are_supported
CSV.open(@path, col_sep: "\t", row_sep: "\r\n") do |csv|
enum = csv.each
assert_instance_of(Enumerator, enum)
assert_equal(@expected.shift, enum.next)
end
end
### Test Write Interface ###
def test_generate