Pausable script

Hi everyone,

I’m trying to build a script that writes something every 2 minutes. This
is what I have so far, but I would like to make it so that I can pause
it, with a certain key, and make it continue with another key. When it
is unpaused it should keep track where it left off.

Any ideas how to do this?

40.times do |i|
puts i
sleep(200);
puts “write something”
end

Ted

On Mon, Oct 25, 2010 at 3:26 PM, Ted F. [email protected]
wrote:

puts i
sleep(200);
puts “write something”
end

You could replace the sleep(200) with a loop doing something like:
sleeping a small amount of time (e.g.: 100ms), checking if there’s
user input available, act accordingly and sleeping again.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs