I am trying to print "Please input a value"
and raise a Timeout::Error
if input is not received in 2 seconds.
I thought I could do:
puts "Please input a value"
Timeout.timeout(2) do
ans = gets
end
raise "aborted" unless ans == 'y'
When I run the script, it prints the message, and then just sits. If I enter a value after 10 seconds (for example), then it times out. It doesn't hit the timeout until after I input a value.