Forum: Ruby Re: Shame on me poorr newbie " unexpected kend"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kroeger, Simon (ext) (Guest)
on 2006-04-13 18:57
(Received via mailing list)
>    loop do
> end
>      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.
G.Durga P. (Guest)
on 2006-04-13 19:31
(Received via mailing list)
On 4/13/06, Kroeger, Simon (ext) <removed_email_address@domain.invalid> wrote:
> >
> >      end
> >        @procdata = usb
> def ask(msg)
>    puts "We are now trying to find the device"
>
> cheers
>
> Simon
>
> p.s.: I have no /proc/scsi/usb-storage (win2000) so this is untested.
>
>
Tested and am glad to get the following:
$ ruby find_usbdev.rb
We are now trying to find the device
Found in /proc/scsi/usb-storage/3:    Host scsi3: usb-storage
       Vendor: SanDisk Corporation
      Product: Cruzer Mini
Serial Number: 2004351462080892ebd0
     Protocol: Transparent SCSI
    Transport: Bulk
       Quirks:
. Is this your
device? [y/n]: y

Prasad
This topic is locked and can not be replied to.