Module: Hive::Idler::Utilities

Included in:
Hive::Idler
Defined in:
lib/hive/idler.rb

Instance Method Summary collapse

Instance Method Details

#wait_until(timeout = 1, &test) ⇒ Object

execute test repeatedly, until timeout, or until test returns true



70
71
72
73
74
75
76
77
# File 'lib/hive/idler.rb', line 70

def wait_until( timeout = 1, &test )
  tester = Hive::Idler.new(test)
  finish = Time.now.to_f + timeout
  loop do
    break if tester.call
    break if finish < Time.now.to_f
  end
end