Class: SystemdMon::StateValue
- Inherits:
-
Object
- Object
- SystemdMon::StateValue
- Defined in:
- lib/systemd_mon/state_value.rb
Instance Attribute Summary collapse
-
#failure_states ⇒ Object
readonly
Returns the value of attribute failure_states.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ok_states ⇒ Object
readonly
Returns the value of attribute ok_states.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #display_name ⇒ Object
- #fail? ⇒ Boolean
- #important? ⇒ Boolean
-
#initialize(name, value, timestamp, ok_states = [], failure_states = []) ⇒ StateValue
constructor
A new instance of StateValue.
- #ok? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, value, timestamp, ok_states = [], failure_states = []) ⇒ StateValue
Returns a new instance of StateValue.
5 6 7 8 9 10 11 |
# File 'lib/systemd_mon/state_value.rb', line 5 def initialize(name, value, , ok_states = [], failure_states = []) self.name = name self.value = value self.ok_states = ok_states self.failure_states = failure_states self. = end |
Instance Attribute Details
#failure_states ⇒ Object
Returns the value of attribute failure_states.
3 4 5 |
# File 'lib/systemd_mon/state_value.rb', line 3 def failure_states @failure_states end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/systemd_mon/state_value.rb', line 3 def name @name end |
#ok_states ⇒ Object
Returns the value of attribute ok_states.
3 4 5 |
# File 'lib/systemd_mon/state_value.rb', line 3 def ok_states @ok_states end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/systemd_mon/state_value.rb', line 3 def end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/systemd_mon/state_value.rb', line 3 def value @value end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 |
# File 'lib/systemd_mon/state_value.rb', line 41 def ==(other) other.is_a?(SystemdMon::StateValue) && value == other.value end |
#display_name ⇒ Object
13 14 15 |
# File 'lib/systemd_mon/state_value.rb', line 13 def display_name name.capitalize end |
#fail? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/systemd_mon/state_value.rb', line 29 def fail? if failure_states.any? failure_states.include?(value) else false end end |
#important? ⇒ Boolean
17 18 19 |
# File 'lib/systemd_mon/state_value.rb', line 17 def important? ok_states.include?(value) || failure_states.include?(value) end |
#ok? ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/systemd_mon/state_value.rb', line 21 def ok? if ok_states.any? ok_states.include?(value) else true end end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/systemd_mon/state_value.rb', line 37 def to_s value end |