Class: ThresholdCheck
- Inherits:
-
Struct
- Object
- Struct
- ThresholdCheck
- Defined in:
- lib/cane/threshold_check.rb
Overview
Configurable check that allows the contents of a file to be compared against a given value.
Defined Under Namespace
Classes: UnavailableValue
Instance Attribute Summary collapse
-
#checks ⇒ Object
Returns the value of attribute checks.
Instance Method Summary collapse
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks
5 6 7 |
# File 'lib/cane/threshold_check.rb', line 5 def checks @checks end |
Instance Method Details
#value_from_file(file) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cane/threshold_check.rb', line 16 def value_from_file(file) begin contents = File.read(file).chomp.to_f rescue Errno::ENOENT UnavailableValue.new end end |
#violations ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/cane/threshold_check.rb', line 6 def violations checks.map do |operator, file, limit| value = value_from_file(file) unless value.send(operator, limit.to_f) ThresholdViolation.new(file, operator, value, limit) end end.compact end |