Class: Sr71::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/sr71/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Service

Returns a new instance of Service.



3
4
5
6
7
# File 'lib/sr71/service.rb', line 3

def initialize(attrs = {})
  @url        = attrs["url"]
  @interval   = attrs["interval"]
  @last_check = 0
end

Instance Method Details

#needs_check?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/sr71/service.rb', line 9

def needs_check?
  (@last_check + @interval) <= Time.now.to_f
end

#start_checkObject



13
14
15
16
# File 'lib/sr71/service.rb', line 13

def start_check
  @last_check = Time.now.to_f
  HttpCheck.check(@url)
end