Class: Poller::Timeout

Inherits:
Object
  • Object
show all
Defined in:
lib/poller/timeout.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


12
13
14
# File 'lib/poller/timeout.rb', line 12

def occured?
  Time.now - @start_time >= @period
end