Class: DRbQS::Server::CheckAlive

Inherits:
Object
  • Object
show all
Defined in:
lib/drbqs/server/check_alive.rb

Constant Summary collapse

DEFAULT_INTERVAL_TIME =
300

Instance Method Summary collapse

Constructor Details

#initialize(interval) ⇒ CheckAlive

Returns a new instance of CheckAlive.



6
7
8
9
10
11
12
# File 'lib/drbqs/server/check_alive.rb', line 6

def initialize(interval)
  @interval = interval || DEFAULT_INTERVAL_TIME
  if !(Numeric === @interval) || @interval < 0
    raise ArgumentError, "Invalid interval time."
  end
  @last = Time.now
end

Instance Method Details

#set_checkingObject



18
19
20
# File 'lib/drbqs/server/check_alive.rb', line 18

def set_checking
  @last = Time.now
end

#significant_interval?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/drbqs/server/check_alive.rb', line 14

def significant_interval?
  (Time.now - @last) >= @interval
end