Class: Poller::Timeout
- Inherits:
-
Object
- Object
- Poller::Timeout
- Defined in:
- lib/poller/timeout.rb
Instance Method Summary collapse
-
#initialize(period_seconds) ⇒ Timeout
constructor
- Specify the timeout period in Integer or Floating Point representation
period_seconds
-
The timeout period in seconds.
- Specify the timeout period in Integer or Floating Point representation
-
#occured? ⇒ Boolean
Returns true if timeout period has elapsed.
Constructor Details
#initialize(period_seconds) ⇒ Timeout
Specify the timeout period in Integer or Floating Point representation
period_seconds
-
The timeout period in seconds
6 7 8 9 |
# File 'lib/poller/timeout.rb', line 6 def initialize(period_seconds) @period = period_seconds @start_time = Time.now end |
Instance Method Details
#occured? ⇒ Boolean
Returns true if timeout period has elapsed
12 13 14 |
# File 'lib/poller/timeout.rb', line 12 def occured? Time.now - @start_time >= @period end |