Class: IPVSLitmus::Health
- Inherits:
-
Object
- Object
- IPVSLitmus::Health
- Defined in:
- lib/ipvs_litmus/health.rb
Instance Attribute Summary collapse
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
- #ensure(dependency) ⇒ Object
-
#initialize ⇒ Health
constructor
A new instance of Health.
- #ok? ⇒ Boolean
- #perform(metric) ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize ⇒ Health
Returns a new instance of Health.
6 7 8 9 10 |
# File 'lib/ipvs_litmus/health.rb', line 6 def initialize @value = 0 @dependencies_available = true @summary = "" end |
Instance Attribute Details
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
4 5 6 |
# File 'lib/ipvs_litmus/health.rb', line 4 def summary @summary end |
Instance Method Details
#ensure(dependency) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/ipvs_litmus/health.rb', line 28 def ensure(dependency) available = dependency.available? @dependencies_available &&= available @summary << "#{dependency.class}: #{available ? 'OK' : 'FAIL'}\n" end |
#ok? ⇒ Boolean
12 13 14 |
# File 'lib/ipvs_litmus/health.rb', line 12 def ok? value > 0 end |
#perform(metric) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ipvs_litmus/health.rb', line 21 def perform(metric) health = metric.current_health @value += health @summary << "#{metric.class}: #{health}\n" end |
#value ⇒ Object
16 17 18 19 |
# File 'lib/ipvs_litmus/health.rb', line 16 def value return 0 unless @dependencies_available @value end |