David Vallner wrote:
> Ben Thomas wrote:
>> Hi all,
>>
>> Only just started using ruby so this may be really simple to do, but
>> here goes:
>>
>> I'm trying to write a program that asks a user to enter their sex using
>> "gets" but if the user doesn't type anything for about 5 seconds I want
>> to print a message, like "Please enter something..." then go back to the
>> gets prompt. I've tried using the "sleep x" method but it doesn't seem
>> to work because once gets has been initiated it gets stuck there until
>> something is entered.
>>
>> Oh I don't have to use gets, but this is the only method of input I'm
>> aware of at the moment
>>
>> Hope this makes sense,
>> Ben
>>
>>
> 
> Read the data in a thread, or use nonblocking io (currently crude at
> best, with only eventmachine to help as a project that shown up on my
> radar - and that seems to be oriented towards networking)
> 
> Also, what you describe there is a very rude thing to do to your user,
> basically you're accusing them of having no attention span and the
> program is attention-seeking to compensate.
> 
> David Vallner
> 

Yeah, I'd never even think of doing it normally, it was just put in a 
small program specification for uni. It's not an assignment or anything 
so I'll probably just leave that part out if it's hard to implement.

The part of the specification was:

	3. Keep the program running until the user shouts ţYE If, 			while 
the program is running, nothing is happening Grandma 			should shout 
ŸHAT? CAT GOT YOUR TONGUE? SPEAK UP, I SAY!"


I'll just leave the "cat got your tongue" part out for now. Managed to 
keep the program running until the user shouts "BYE" easy enough, just 
the second part causing problems.

Thanks for the help.