Force enter in gets

J

Jack Bauer

Hi all,

Let's say I have a ruby script that gets some user input:

name = gets

How can I make it so after 10 seconds of no input (or even if they start
typing, it'll cut them off after 10 seconds) it will continue? In other
words, essentially simulate the return key after 10 seconds.
 
B

Bertram Scharpf

Hi,

Am Freitag, 25. Sep 2009, 01:35:46 +0900 schrieb Jack Bauer:
Let's say I have a ruby script that gets some user input:

name = gets

How can I make it so after 10 seconds of no input (or even if they start
typing, it'll cut them off after 10 seconds) it will continue? In other
words, essentially simulate the return key after 10 seconds.

name = if select [$stdin], nil, nil, 10 then gets else "Joe" end

Bertram
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,167
Messages
2,570,913
Members
47,455
Latest member
Delilah Code

Latest Threads

Top