Class: HttpPulse::Response::Monitor
- Inherits:
-
Object
- Object
- HttpPulse::Response::Monitor
- Defined in:
- lib/http-pulse/response.rb
Instance Method Summary collapse
- #checked_at ⇒ Object
- #checked_at_time ⇒ Object
-
#initialize(json) ⇒ Monitor
constructor
A new instance of Monitor.
- #status ⇒ Object
- #to_s ⇒ Object
- #up? ⇒ Boolean
- #url ⇒ Object
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_at ⇒ Object
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_time ⇒ Object
24 25 26 |
# File 'lib/http-pulse/response.rb', line 24 def checked_at_time Time.parse(@json['lastChecked']).localtime end |
#status ⇒ Object
16 17 18 |
# File 'lib/http-pulse/response.rb', line 16 def status up? ? "UP" : "DOWN" end |
#to_s ⇒ Object
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
12 13 14 |
# File 'lib/http-pulse/response.rb', line 12 def up? @json['httpStatus'] == 200 end |
#url ⇒ Object
8 9 10 |
# File 'lib/http-pulse/response.rb', line 8 def url @json['url'] end |