Class: Nagios::Check::Range
- Inherits:
-
Object
- Object
- Nagios::Check::Range
- Defined in:
- lib/nagios-check/range.rb
Instance Attribute Summary collapse
-
#alert_on ⇒ Object
readonly
Returns the value of attribute alert_on.
-
#end_infinity ⇒ Object
readonly
Returns the value of attribute end_infinity.
-
#end_value ⇒ Object
readonly
Returns the value of attribute end_value.
-
#start_infinity ⇒ Object
readonly
Returns the value of attribute start_infinity.
-
#start_value ⇒ Object
readonly
Returns the value of attribute start_value.
Instance Method Summary collapse
- #check_range(value) ⇒ Object
-
#initialize(range) ⇒ Range
constructor
A new instance of Range.
Constructor Details
#initialize(range) ⇒ Range
Returns a new instance of Range.
7 8 9 10 11 12 13 14 |
# File 'lib/nagios-check/range.rb', line 7 def initialize(range) @start_value = 0 @end_value = 0 @start_infinity = false @end_infinity = false @alert_on = :inside parse_range_string(range.to_s) end |
Instance Attribute Details
#alert_on ⇒ Object (readonly)
Returns the value of attribute alert_on.
5 6 7 |
# File 'lib/nagios-check/range.rb', line 5 def alert_on @alert_on end |
#end_infinity ⇒ Object (readonly)
Returns the value of attribute end_infinity.
5 6 7 |
# File 'lib/nagios-check/range.rb', line 5 def end_infinity @end_infinity end |
#end_value ⇒ Object (readonly)
Returns the value of attribute end_value.
5 6 7 |
# File 'lib/nagios-check/range.rb', line 5 def end_value @end_value end |
#start_infinity ⇒ Object (readonly)
Returns the value of attribute start_infinity.
5 6 7 |
# File 'lib/nagios-check/range.rb', line 5 def start_infinity @start_infinity end |
#start_value ⇒ Object (readonly)
Returns the value of attribute start_value.
5 6 7 |
# File 'lib/nagios-check/range.rb', line 5 def start_value @start_value end |
Instance Method Details
#check_range(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nagios-check/range.rb', line 16 def check_range(value) value = value.to_f result = if !start_infinity && end_infinity start_value <= value elsif start_infinity && !end_infinity value <= end_value else start_value <= value && value <= end_value end alert_on == :outside ? result : !result end |