I'm looking to create a Ruby (MRI 1.9.3) loop that runs at most for a certain amount of time, and once that time is up it goes to the next iteration of the loop.
For example, this is what I'm hoping to achieve:
timer = Timer.new
timer.after 5 do # The loop on foo only gets to run for 5 seconds
# Do some work here
require 'timeout' timeout_in_seconds = 5 while foo begin Timeout::timeout(timeout_in_seconds) do # Do some work here end rescue Timeout::Error next end end