Sha256: 9e0548838b2d446db9f0f2c1c1536529c6e90dcb31488564b6545d75d451d821
Contents?: true
Size: 487 Bytes
Versions: 4
Compression:
Stored size: 487 Bytes
Contents
require 'time' class Wait ## # Execute a block until it returns true. # Optionally pass a timeout (by default 5 seconds). # # wait = Wait.new # wait.until { # (Random.rand(2) % 2) # } # # wait.until(:timeout => 4) { # (Random.rand(2) % 2) # } # def Wait.until(options={:timeout => 5}) timeout = Time.new + options[:timeout].to_f while (Time.new < timeout) return if (yield) end raise 'Timeout exceeded for wait until.' end end
Version data entries
4 entries across 4 versions & 1 rubygems