Class: Timer
- Inherits:
-
Object
- Object
- Timer
- Defined in:
- lib/waitfor/timer.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(seconds, exception_message = "Timeout Error Waiting for Event") ⇒ Timer
constructor
A new instance of Timer.
- #out_of_time? ⇒ Boolean
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, = "Timeout Error Waiting for Event" ) @seconds = seconds @exception_message = @start_time = Time.now end |
Instance Method Details
#out_of_time? ⇒ Boolean
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 |