Class: Easymon::Result
- Inherits:
-
Object
- Object
- Easymon::Result
- Defined in:
- lib/easymon/result.rb
Instance Attribute Summary collapse
-
#critical ⇒ Object
Returns the value of attribute critical.
-
#message ⇒ Object
Returns the value of attribute message.
-
#success ⇒ Object
Returns the value of attribute success.
-
#timing ⇒ Object
Returns the value of attribute timing.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(result, timing, is_critical = false) ⇒ Result
constructor
A new instance of Result.
- #is_critical? ⇒ Boolean
- #response_status ⇒ Object
- #success? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(result, timing, is_critical = false) ⇒ Result
Returns a new instance of Result.
8 9 10 11 12 13 |
# File 'lib/easymon/result.rb', line 8 def initialize(result, timing, is_critical = false) self.success = result[0] self. = result[1] self.timing = timing self.critical = is_critical end |
Instance Attribute Details
#critical ⇒ Object
Returns the value of attribute critical.
6 7 8 |
# File 'lib/easymon/result.rb', line 6 def critical @critical end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/easymon/result.rb', line 4 def @message end |
#success ⇒ Object
Returns the value of attribute success.
3 4 5 |
# File 'lib/easymon/result.rb', line 3 def success @success end |
#timing ⇒ Object
Returns the value of attribute timing.
5 6 7 |
# File 'lib/easymon/result.rb', line 5 def timing @timing end |
Instance Method Details
#as_json(options = {}) ⇒ Object
31 32 33 |
# File 'lib/easymon/result.rb', line 31 def as_json( = {}) to_hash end |
#is_critical? ⇒ Boolean
19 20 21 |
# File 'lib/easymon/result.rb', line 19 def is_critical? critical end |
#response_status ⇒ Object
23 24 25 |
# File 'lib/easymon/result.rb', line 23 def response_status success? ? :ok : :service_unavailable end |
#success? ⇒ Boolean
15 16 17 |
# File 'lib/easymon/result.rb', line 15 def success? success end |
#to_hash ⇒ Object
35 36 37 |
# File 'lib/easymon/result.rb', line 35 def to_hash {:success => success, :message => , :timing => Easymon.timing_to_ms(timing), :critical => critical} end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/easymon/result.rb', line 27 def to_s "#{} - #{Easymon.timing_to_ms(timing)}ms" end |