Module: Gametel::Waiter

Included in:
Gametel, Navigation
Defined in:
lib/gametel/waiter.rb

Defined Under Namespace

Classes: Timeout

Instance Method Summary collapse

Instance Method Details

#wait_until(timeout = 10, message = nil, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/gametel/waiter.rb', line 15

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