lib/array_hasher.rb in array_hasher-0.1.3 vs lib/array_hasher.rb in array_hasher-0.1.4
- old
+ new
@@ -25,9 +25,13 @@
def csv_each(path, ext_types = {}, &block)
csv = CSV.open(path)
formatter = new_formatter(parse_format(csv.gets))
formatter.types.merge!(ext_types)
- csv.each { |line| block.call(formatter.parse(line)) }
+ if block
+ csv.each { |line| block.call(formatter.parse(line)) }
+ else
+ Enumerator.new { |y| csv.each { |line| y << formatter.parse(line) } }
+ end
end
end
end