1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/core/wait_for.rb
Aaron Suggs 82517cde36 [core] Cast Fog.wait_for interval to float.
sleep() is strict. Allow more liberal values like
ActiveSupport::Durations:

   Fog.wait(1.hour, 10.seconds) { … }
2011-11-30 12:35:13 -05:00

17 lines
318 B
Ruby

module Fog
def self.wait_for(timeout=Fog.timeout, interval=1, &block)
duration = 0
start = Time.now
until yield || duration > timeout
sleep(interval.to_f)
duration = Time.now - start
end
if duration > timeout
false
else
{ :duration => duration }
end
end
end