Tom Werner
7/19/2006 7:14:00 PM
Ryan Edwards-crewe wrote:
> Forgot to mention I'm trying to match an 8 digit number, but I pretty
> sure it's being stored as a string.
>
> I am taking the values from an Excel worksheet
>
> po_number = worksheet.Range("#{col}#{row}").value
>
> if po_number.length == 8 #the standard Purchase Order length
> aPOlist.append(PurchaseOrder.new("#{po_number}", "#{notes}",
> "#{company}", "#{unit_config}", "#{due_date}", "#{quantity.to_i}"))
> end
>
>
Don't forget to chomp the input to get rid of the newline:
irb(main):001:0> val = gets
12345678
=> "12345678\n"
irb(main):002:0> val = gets.chomp
12345678
=> "12345678"
irb(main):003:0>
Also, instead of doing
for i in 0..aPOlist.length
#code
end
a prettier way is
aPOlist.each_index do |i|
#code
end
--
Tom Werner
Helmets to Hardhats
Software Developer
tom@helmetstohardhats.org
www.helmetstohardhats.org