Class: MonitorType_Threshold
- Inherits:
-
MonitorType
- Object
- MonitorType
- MonitorType_Threshold
- Defined in:
- lib/MonitorType/Threshold.rb
Direct Known Subclasses
Instance Method Summary collapse
- #check(value, context_sentence) ⇒ Object
-
#initialize(params) ⇒ MonitorType_Threshold
constructor
A new instance of MonitorType_Threshold.
Methods inherited from MonitorType
#alert, #process, #run, #sanitise
Constructor Details
#initialize(params) ⇒ MonitorType_Threshold
4 5 6 7 8 |
# File 'lib/MonitorType/Threshold.rb', line 4 def initialize( params ) @min = params[:min] ||= 0 @max = params[:max] super( params ) end |
Instance Method Details
#check(value, context_sentence) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/MonitorType/Threshold.rb', line 10 def check( value, context_sentence ) value = value.to_i if !@min.nil? && value < @min then self.alert( "#{context_sentence}\nMinimum threshold exceeded. Minimum: #{@min}, Actual: #{value}" ) end if !@max.nil? && value > @max then self.alert( "#{context_sentence}\nMaximum threshold exceeded. Maximum: #{@max}, Actual: #{value}" ) end end |