Sha256: dd93cb688c03da5ee5a7ec3c6edb13247b11e2fbe3074a49881d5af9a302a2f5
Contents?: true
Size: 734 Bytes
Versions: 2
Compression:
Stored size: 734 Bytes
Contents
module Pagetience class Meditate attr_accessor :timeout, :polling, :block def initialize(timeout=30, polling=1, &block) @timeout = timeout @polling = polling @block = block end def until_enlightened(expected=nil, msg='Timed out waiting for the expected result.') raise ArgumentError, 'Timeout cannot be lower than the polling value.' unless @timeout > @polling while @timeout > 0 && @timeout > @polling @latest_result = @block.call break unless expected && @latest_result != expected sleep @polling @timeout = @timeout - @polling end raise Pagetience::Exceptions::Timeout, msg unless @latest_result @latest_result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pagetience-0.2.1 | lib/pagetience/meditate.rb |
pagetience-0.2.0 | lib/pagetience/meditate.rb |