Take a look at the source here. At the time of writing, CSV::foreach
is defined as
def self.foreach(path, options = Hash.new, &block)
open(path, options) do |csv|
csv.each(&block)
end
end
so the each
enumerator is enclosed within the open
block and the method returns nil
. If you want to interact w/ the enumerator you can do something like
CSV.open('file.csv') do |csv|
csv.each.map do |row|
# whatever
end
end