Class: SystemdMon::UnitWithState
- Inherits:
-
Object
- Object
- SystemdMon::UnitWithState
- Defined in:
- lib/systemd_mon/unit_with_state.rb
Instance Attribute Summary collapse
-
#state_change ⇒ Object
readonly
Returns the value of attribute state_change.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
Instance Method Summary collapse
- #<<(state) ⇒ Object
- #current_state ⇒ Object (also: #state)
-
#initialize(unit) ⇒ UnitWithState
constructor
A new instance of UnitWithState.
- #name ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(unit) ⇒ UnitWithState
Returns a new instance of UnitWithState.
7 8 9 10 |
# File 'lib/systemd_mon/unit_with_state.rb', line 7 def initialize(unit) self.unit = unit self.state_change = StateChange.new end |
Instance Attribute Details
#state_change ⇒ Object
Returns the value of attribute state_change.
5 6 7 |
# File 'lib/systemd_mon/unit_with_state.rb', line 5 def state_change @state_change end |
#unit ⇒ Object
Returns the value of attribute unit.
5 6 7 |
# File 'lib/systemd_mon/unit_with_state.rb', line 5 def unit @unit end |
Instance Method Details
#<<(state) ⇒ Object
16 17 18 |
# File 'lib/systemd_mon/unit_with_state.rb', line 16 def <<(state) self.state_change << state end |
#current_state ⇒ Object Also known as: state
20 21 22 |
# File 'lib/systemd_mon/unit_with_state.rb', line 20 def current_state state_change.last end |
#name ⇒ Object
12 13 14 |
# File 'lib/systemd_mon/unit_with_state.rb', line 12 def name unit.name end |
#reset! ⇒ Object
24 25 26 |
# File 'lib/systemd_mon/unit_with_state.rb', line 24 def reset! self.state_change = StateChange.new(current_state) end |