Top Level Namespace
Defined Under Namespace
Classes: WaitFor
Instance Method Summary collapse
Instance Method Details
#wait_for(timeout = 45, &blk) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wait_for.rb', line 12 def wait_for(timeout=45, &blk) if block_given? begin Timeout.timeout(timeout) { while true begin res=blk.call res = res.call if res.respond_to?(:call) sleep 0.2 rescue => e puts "EEEEEEE: #{e.inspect}" res=false #break end break if res end return true } rescue Timeout::Error => e return false end else raise StandardError, "Provide a block which returns true | false" end end |