Class: Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/waitfor/timer.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(seconds, exception_message = "Timeout Error Waiting for Event") ⇒ Timer

Returns a new instance of Timer.



2
3
4
5
6
# File 'lib/waitfor/timer.rb', line 2

def initialize( seconds, exception_message = "Timeout Error Waiting for Event" )
  @seconds           = seconds
  @exception_message = exception_message
  @start_time        = Time.now
end

Instance Method Details

#out_of_time?Boolean

Returns:

  • (Boolean)

Raises:

  • (@exception_message)


8
9
10
11
12
# File 'lib/waitfor/timer.rb', line 8

def out_of_time?
  out_of_time = ( Time.now - @start_time ) > @seconds
  raise @exception_message if out_of_time
  out_of_time
end