Class: BrokenWindow::MetricStatus
- Inherits:
-
Object
- Object
- BrokenWindow::MetricStatus
- Defined in:
- app/models/broken_window/metric_status.rb
Constant Summary collapse
- NAMES =
[:fail, :unknown, :pass]
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(name) ⇒ MetricStatus
constructor
A new instance of MetricStatus.
- #to_s ⇒ Object
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
#value ⇒ Object (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 |
.fail ⇒ Object
14 15 16 |
# File 'app/models/broken_window/metric_status.rb', line 14 def fail new(:fail) end |
.pass ⇒ Object
6 7 8 |
# File 'app/models/broken_window/metric_status.rb', line 6 def pass new(:pass) end |
.unknown ⇒ Object
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_s ⇒ Object
29 30 31 |
# File 'app/models/broken_window/metric_status.rb', line 29 def to_s NAMES[@value].to_s end |