Sha256: 38da1f0ad1d3e8ce8baab56ee93374dd67bea4584f16801b5e331c036ea8e241
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Watir module Wait class Timer def initialize(timeout: nil) @end_time = timeout ? current_time + timeout : nil @remaining_time = @end_time - current_time if @end_time end # # Executes given block until it returns true or exceeds timeout. # @param [Integer] timeout # @yield block # @api private # def wait(timeout, &block) end_time = @end_time || (current_time + timeout) loop do yield(block) @remaining_time = end_time - current_time break if @remaining_time.negative? end end def remaining_time @end_time - current_time end def reset! @end_time = nil end def locked? !@end_time.nil? end private if defined?(Process::CLOCK_MONOTONIC) def current_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end else def current_time ::Time.now.to_f end end end # Timer end # Wait end # Watir
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
watir-7.3.0 | lib/watir/wait/timer.rb |
watir-7.2.2 | lib/watir/wait/timer.rb |
watir-7.2.1 | lib/watir/wait/timer.rb |
watir-7.2.0 | lib/watir/wait/timer.rb |