Sha256: 0262690d14376ba03fede5ea3f15c5cdb99e7d0c39f262d41d08d74f8a4c0a6e

Contents?: true

Size: 466 Bytes

Versions: 1

Compression:

Stored size: 466 Bytes

Contents

module TimeIncrements
  def seconds
    self * 1
  end
  alias_method :second, :seconds
end
class Float
  include TimeIncrements
end
class Fixnum 
  include TimeIncrements
end

def wait_until opts={}
  opts = {:timeout_after => 2.seconds,:retry_every => 0.1.seconds}.merge(opts)
  start_time = Time.now
  until Time.now > start_time + opts[:timeout_after]
    return if yield == true
    sleep opts[:retry_every]
  end
  raise RuntimeError, "Action took to long"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waitforit-0.0.1.pre2 lib/waitforit.rb