Class: BrokenWindow::MetricStatus

Inherits:
Object
  • Object
show all
Defined in:
app/models/broken_window/metric_status.rb

Constant Summary collapse

NAMES =
[:fail, :unknown, :pass]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ MetricStatus

Returns a new instance of MetricStatus.



25
26
27
# File 'app/models/broken_window/metric_status.rb', line 25

def initialize(name)
  @value = NAMES.index(name)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



23
24
25
# File 'app/models/broken_window/metric_status.rb', line 23

def value
  @value
end

Class Method Details

.combine(states) ⇒ Object



18
19
20
# File 'app/models/broken_window/metric_status.rb', line 18

def combine(states)
  states.nil? || states.empty? ? unknown : states.compact.min
end

.failObject



14
15
16
# File 'app/models/broken_window/metric_status.rb', line 14

def fail
  new(:fail)
end

.passObject



6
7
8
# File 'app/models/broken_window/metric_status.rb', line 6

def pass
  new(:pass)
end

.unknownObject



10
11
12
# File 'app/models/broken_window/metric_status.rb', line 10

def unknown
  new(:unknown)
end

Instance Method Details

#<=>(other) ⇒ Object



33
34
35
# File 'app/models/broken_window/metric_status.rb', line 33

def <=>(other)
  value <=> other.value
end

#to_sObject



29
30
31
# File 'app/models/broken_window/metric_status.rb', line 29

def to_s
  NAMES[@value].to_s
end