> -----Original Message-----
> From: Daniel Harple [mailto:dharple / generalconsumption.org] 
> Sent: Thursday, April 13, 2006 4:06 PM
> To: ruby-talk ML
> Subject: Re: Shame on me poorr newbie " unexpected kend"
> 
> Don't use numbers as a substitute for booleans. Also, why are you  
> calling IO.popen? File.read would work fine.
> 
> def ask(msg)
>    loop do
>      print "#{msg} [y/n]: "
>      response = gets().strip
>      if response == "y"
>        return true
>      elsif response == "n"
>        return false
>      else
>        puts "Invalid response. Please enter y or n"
>      end
>    end
> end
> 
> def find_device
>    puts "We are now trying to find the device"
>    store = 0
>    loops do
>      usb_dev = "/proc/scsi/usb-storage/#{store}"
>      usb = File.read(usb_dev)
>      if ask("Found in #{usb_dev}: #{usb}. Is this your device?")
>        @procdata = usb
>        break
>      else
>        store += 1
>      end
>    end
> end

and you can simplify this even more:
------------------------------------------------------------------------
-
def ask(msg)
   loop do
     print "#{msg} [y/n]: "
     response = gets().strip
     return true if response == 'y'
     return false if response == 'n'
     puts "Invalid response. Please enter y or n"
   end
end

def find_device
   puts "We are now trying to find the device"
   Dir["/proc/scsi/usb-storage/*"].each do |usb_dev|
     usb = File.read(usb_dev)
     return usb if ask("Found in #{usb_dev}: #{usb}. Is this your
device?")
   end && nil
end

procdata = find_device
------------------------------------------------------------------------
-

cheers

Simon

p.s.: I have no /proc/scsi/usb-storage (win2000) so this is untested.