Sha256: 5ea86da229eec45e875dcb9937e987cbef5dac33f0213795055542c8298eca4d

Contents?: true

Size: 483 Bytes

Versions: 3

Compression:

Stored size: 483 Bytes

Contents

# frozen_string_literal: true

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

3 entries across 3 versions & 1 rubygems

Version Path
cistern-2.10.0 lib/cistern/timeout.rb
cistern-2.8.2 lib/cistern/timeout.rb
cistern-2.8.1 lib/cistern/timeout.rb