Sha256: b86f13ae088f633cf36d14c696fc87e4565c2443785ccafba8c7e26684d0f13d

Contents?: true

Size: 452 Bytes

Versions: 13

Compression:

Stored size: 452 Bytes

Contents

module Cistern
  module WaitFor
    def self.wait_for(timeout = Cistern.timeout, interval = Cistern.poll_interval, &_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

    def self.wait_for!(*_arg)
      wait_for
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cistern-2.8.0 lib/cistern/timeout.rb
cistern-2.7.2 lib/cistern/timeout.rb
cistern-2.7.1 lib/cistern/timeout.rb
cistern-2.7.0 lib/cistern/timeout.rb
cistern-2.6.0 lib/cistern/timeout.rb
cistern-2.5.0 lib/cistern/timeout.rb
cistern-2.4.1 lib/cistern/timeout.rb
cistern-2.4.0 lib/cistern/timeout.rb
cistern-2.3.0 lib/cistern/timeout.rb
cistern-2.2.7 lib/cistern/timeout.rb
cistern-2.2.6 lib/cistern/timeout.rb
cistern-2.2.5 lib/cistern/timeout.rb
cistern-2.2.4 lib/cistern/timeout.rb