Class: SystemdMon::UnitWithState

Inherits:
Object
  • Object
show all
Defined in:
lib/systemd_mon/unit_with_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_changeObject

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

#unitObject

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_stateObject Also known as: state



20
21
22
# File 'lib/systemd_mon/unit_with_state.rb', line 20

def current_state
  state_change.last
end

#nameObject



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