Sha256: 8b6feafaea0a05cbfb06b869d9962ce4857b9a6275b856b1dcb1593faf9b6e54

Contents?: true

Size: 568 Bytes

Versions: 10

Compression:

Stored size: 568 Bytes

Contents

module Gametel
  module Waiter
    class Timeout < StandardError
      def initialize(waiting_for=nil)
        super(waiting_for)
        @waiting_for = waiting_for
      end

      def to_s
        return super unless @waiting_for
        "Timed out waiting for #{@waiting_for}"
      end
    end

    def wait_until(timeout=10, message=nil, &block)
      last_call = ::Time.now + timeout
      while ::Time.now < last_call
        stoppit = block.call if block
        return if stoppit
        sleep 0.1
      end

      raise Timeout.new message
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gametel-0.8 lib/gametel/waiter.rb
gametel-0.7 lib/gametel/waiter.rb
gametel-0.6 lib/gametel/waiter.rb
gametel-0.5.9.3 lib/gametel/waiter.rb
gametel-0.5.9.2 lib/gametel/waiter.rb
gametel-0.5.9.1 lib/gametel/waiter.rb
gametel-0.5.9 lib/gametel/waiter.rb
gametel-0.5.8.1 lib/gametel/waiter.rb
gametel-0.5.8 lib/gametel/waiter.rb
gametel-0.5.7 lib/gametel/waiter.rb