I am parsing a text file that is 3 fields per line deliminted by pipes
Each line contains a customer code, shipmethod, and customer name.
Each line represents an invoice that was cut.
I need to count all invoices and then count all invoices that went out
day air saver.
From working with the pick axe it seems to me that you have a class with
attributes invoice, and nda invoice.
You then store your objects in a hash for easy lookup.
When i run the below program I get this error…
incndainvoice': undefined method+’ for nil:NilClass
Here is my class and program …
attr_reader :invoices, :ndainvoices
attr_writer :invoices, :ndainvoices
@invoices = 1
@ndainvoices = 0
invoices = invoices + 1
ndainvoice = ndainvoice + 1
customers = Hash.new
open(‘NdaInvoiceCount.txt’,‘r’).each_line do |line|
(customer_code, ship_method, customer_name) =
if customers[ customer_code ]
customers[ customer_code ].increment_invoice
customers[ customer_code ] = Customer.new
customers[ customer_code ].increment_ndainvoice if ship_method
here is some sample data…
0000038955|SAVGRD|TRUDELL ORTH & PROS SERVICES
0000019155|UPS |Scott Orthotic Labs
0000061674|UPS |COMPREHENSIVE BRACE & LIMB CTR LLC
0000008593|U02G |Huron Valley Assoc
0000039954|SAVGRD|Island Coast Orthopedics
0000028719|UPS |Paul Richelson’s Feet First
0000019297|UPS |J. Slawner LTD.
0000061508|UPS |LEVY & RAPPEL