Class: Dekiru::Capybara::Helpers::WaitForPositionStable::StableTimer

Inherits:
Object
  • Object
show all
Defined in:
lib/dekiru/capybara/helpers/wait_for_position_stable.rb

Instance Method Summary collapse

Constructor Details

#initialize(wait) ⇒ StableTimer

Returns a new instance of StableTimer.



6
7
8
9
10
11
# File 'lib/dekiru/capybara/helpers/wait_for_position_stable.rb', line 6

def initialize(wait)
  @wait = wait
  @stable = false
  @start_time = nil
  @prev_obj = nil
end

Instance Method Details

#stable?(obj) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dekiru/capybara/helpers/wait_for_position_stable.rb', line 13

def stable?(obj)
  if @prev_obj && @prev_obj == obj
    if @start_time.nil?
      @start_time = current
    elsif current - @start_time > @wait
      return true
    end
  else
    @start_time = nil
  end
  @prev_obj = obj
  false
end