Class: Capybara::UI::Checkpoint::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/ui/checkpoint.rb

Defined Under Namespace

Classes: Frozen

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration) ⇒ Timer

Returns a new instance of Timer.


20
21
22
# File 'lib/capybara/ui/checkpoint.rb', line 20

def initialize(duration)
  @duration = duration
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration


24
25
26
# File 'lib/capybara/ui/checkpoint.rb', line 24

def duration
  @duration
end

Instance Method Details

#elapsedObject


30
31
32
# File 'lib/capybara/ui/checkpoint.rb', line 30

def elapsed
  now - start_time
end

#expired?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/capybara/ui/checkpoint.rb', line 26

def expired?
  duration < elapsed
end

#startObject


34
35
36
# File 'lib/capybara/ui/checkpoint.rb', line 34

def start
  @start_time = now
end

#tickObject

Raises:


38
39
40
41
42
# File 'lib/capybara/ui/checkpoint.rb', line 38

def tick
  sleep tick_duration

  raise Frozen, 'time appears to be frozen' if frozen?
end