From: alex mic Date: 2006-04-14T02:44:32+09:00 Subject: Re: Shame on me poorr newbie " unexpected kend" Well obviously when I wrote "final method" I meant "possibly working method yet very dirty one". Daniel Harple wrote: > Don't use numbers as a substitute for booleans. Yes sir! Just to mention that I haven't coded for years and that TIMTOWTDI is a friend I tend to rely on *too much*. Also, why are you > calling IO.popen? File.read would work fine. Of course. Well codind on a XP for linux is not always the best way to proceed... Please pitty my condition, as having access to the files is sometimes helpfull. > 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 > > > -- Daniel Well, this is more clean not to mention lines saving (I bet you gessed this was not the only question of my piece of software) and reader friendly. Your help is greatly appriciated, so thanks again. Alex. -- Posted via http://www.ruby-forum.com/.