Class: AppHealth::Server
- Inherits:
-
Object
- Object
- AppHealth::Server
- Defined in:
- lib/apphealth/server.rb
Instance Attribute Summary collapse
-
#checked ⇒ Object
Returns the value of attribute checked.
-
#code ⇒ Object
Returns the value of attribute code.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#host ⇒ Object
Returns the value of attribute host.
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #check(uri) ⇒ Object
-
#initialize(host) ⇒ Server
constructor
A new instance of Server.
- #unchecked? ⇒ Boolean
Constructor Details
#initialize(host) ⇒ Server
Returns a new instance of Server.
5 6 7 8 9 10 11 |
# File 'lib/apphealth/server.rb', line 5 def initialize(host) @host = host @checked = false @message = nil @code = nil @duration = nil end |
Instance Attribute Details
#checked ⇒ Object
Returns the value of attribute checked.
3 4 5 |
# File 'lib/apphealth/server.rb', line 3 def checked @checked end |
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/apphealth/server.rb', line 3 def code @code end |
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/apphealth/server.rb', line 3 def duration @duration end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/apphealth/server.rb', line 3 def host @host end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/apphealth/server.rb', line 3 def @message end |
Instance Method Details
#check(uri) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/apphealth/server.rb', line 17 def check(uri) return self if checked benchmark = Benchmark.measure do request = make_request(uri) @code = request.code @message = request. end @duration = (benchmark.real*1000).round @checked = true self end |
#unchecked? ⇒ Boolean
13 14 15 |
# File 'lib/apphealth/server.rb', line 13 def unchecked? @checked == false end |