Class: IPVSLitmus::Health

Inherits:
Object
  • Object
show all
Defined in:
lib/ipvs_litmus/health.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHealth

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

#summaryObject (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

Returns:

  • (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

#valueObject



16
17
18
19
# File 'lib/ipvs_litmus/health.rb', line 16

def value
  return 0 unless @dependencies_available
  @value
end