Class: HttpPulse::Response::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/http-pulse/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Monitor

Returns a new instance of Monitor.



4
5
6
# File 'lib/http-pulse/response.rb', line 4

def initialize(json)
  @json = json
end

Instance Method Details

#checked_atObject



20
21
22
# File 'lib/http-pulse/response.rb', line 20

def checked_at
  checked_at_time.strftime("%Y/%m/%d %H:%M %Z")
end

#checked_at_timeObject



24
25
26
# File 'lib/http-pulse/response.rb', line 24

def checked_at_time
  Time.parse(@json['lastChecked']).localtime
end

#statusObject



16
17
18
# File 'lib/http-pulse/response.rb', line 16

def status
  up? ? "UP" : "DOWN"
end

#to_sObject



28
29
30
# File 'lib/http-pulse/response.rb', line 28

def to_s
  "%-45s %5s as of %s" % [url, status, checked_at]
end

#up?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/http-pulse/response.rb', line 12

def up?
  @json['httpStatus'] == 200
end

#urlObject



8
9
10
# File 'lib/http-pulse/response.rb', line 8

def url
  @json['url']
end