Class: Nagios::MkLiveStatus::Wait::Negate
- Inherits:
-
Nagios::MkLiveStatus::Wait
- Object
- Nagios::MkLiveStatus::Wait
- Nagios::MkLiveStatus::Wait::Negate
- Includes:
- Nagios::MkLiveStatus
- Defined in:
- lib/nagios_mklivestatus/wait/negate.rb
Overview
This class is used to make a logical “NOT” operator for the expression.
- Author
-
Esco-lan Team ([email protected])
- Copyright
-
Copyright © 2012 GIP RECIA
- License
-
General Public Licence
Instance Method Summary collapse
-
#get_expression ⇒ Object
Return the expression under the “Negate”.
-
#initialize(expr) ⇒ Negate
constructor
Create a new “Not” operator to the expression.
-
#to_s ⇒ Object
Convert the current “Negate” expression into a nagios query string.
Methods included from Nagios::MkLiveStatus
Constructor Details
#initialize(expr) ⇒ Negate
Create a new “Not” operator to the expression.
Those expressions must be of type Nagios::MkLiveStatus::Wait
15 16 17 18 19 20 21 22 |
# File 'lib/nagios_mklivestatus/wait/negate.rb', line 15 def initialize(expr) if not check_valid_condition expr raise QueryException.new("The operand for a NEGATE expression must be one valid wait condition.") end @expression = expr end |
Instance Method Details
#get_expression ⇒ Object
Return the expression under the “Negate”. It’s used by the to_s method in order to remove the overflow of Negate expression.
28 29 30 |
# File 'lib/nagios_mklivestatus/wait/negate.rb', line 28 def get_expression return @expression end |
#to_s ⇒ Object
Convert the current “Negate” expression into a nagios query string.
If the sub expression is also a Negate, it returns the sub-sub expression without negating it.
WaitCondition: ...
WaitConditionNegate:
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nagios_mklivestatus/wait/negate.rb', line 39 def to_s if @expression.is_a? Nagios::MkLiveStatus::Wait::Negate return @expression.get_expression.to_s else negate_arr = [] negate_arr.push @expression.to_s negate_arr.push "WaitConditionNegate: " return negate_arr.join("\n") end end |