Class: WebMonitor::ResponseValidator
- Inherits:
-
Object
- Object
- WebMonitor::ResponseValidator
- Defined in:
- lib/web-monitor/response_validator.rb
Overview
Validate response time and status
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #error_msg ⇒ Object
-
#initialize(time, status, config) ⇒ ResponseValidator
constructor
A new instance of ResponseValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(time, status, config) ⇒ ResponseValidator
Returns a new instance of ResponseValidator.
6 7 8 9 |
# File 'lib/web-monitor/response_validator.rb', line 6 def initialize(time, status, config) @time, @status = time.to_f, status.to_i @limit = config.response_time_limit end |
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/web-monitor/response_validator.rb', line 4 def status @status end |
#time ⇒ Object
Returns the value of attribute time.
4 5 6 |
# File 'lib/web-monitor/response_validator.rb', line 4 def time @time end |
Instance Method Details
#error_msg ⇒ Object
15 16 17 18 |
# File 'lib/web-monitor/response_validator.rb', line 15 def error_msg return "Status=#{@status}" unless validate_status return "Time=%.1fs" % @time unless validate_time end |
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/web-monitor/response_validator.rb', line 11 def valid? validate_status and validate_time end |