Randy Kramer
11/2/2007 2:32:00 PM
On Friday 02 November 2007 10:06 am, Zoltar Speaks wrote:
> undefined method `process' for main:Object (NoMethodError)
> from /usr/local/lib/ruby/1.8/csv.rb:560:in `each'
> from solution.rb:4
Have you written/defined a method named "process"--it looks to me like they
(in the book) have used "process" as sort of a generic method--something that
doesn't exist (and isn't defined on that page) that you will have to write
for yourself.
Randy Kramer
> require 'csv'
> reader = CSV.open("csvfile", "r")
> header = reader.shift
> reader.each{|row| process(header, row)}
> CSV.open("csvfile", "r") do |row|
> qty = row[0].to_i
> price = row[2].to_f
> printf "%20s: $%5.2f %s\n", row[1], qty*price, row[3] || " ---"
> end