class SystemdMon::State
Attributes
active[R]
all_states[R]
loaded[R]
sub[R]
unit_file[R]
Public Class Methods
new(active, sub, loaded, unit_file, type=nil)
click to toggle source
# File lib/systemd_mon/state.rb, line 9 def initialize(active, sub, loaded, unit_file, type=nil) timestamp = Time.now @active = StateValue.new("active", active, timestamp, *active_states(type)) @sub = StateValue.new("status", sub, timestamp) @loaded = StateValue.new("loaded", loaded, timestamp, %w(loaded)) @unit_file = StateValue.new("file", unit_file, timestamp, *file_states(type)) @all_states = [@active, @sub, @loaded, @unit_file] end
Public Instance Methods
==(other)
click to toggle source
# File lib/systemd_mon/state.rb, line 54 def ==(other) @all_states == other.all_states end
active_states(type)
click to toggle source
# File lib/systemd_mon/state.rb, line 18 def active_states(type) case type when 'oneshot' [%w(inactive), %w(failed)] else [%w(active), %w(inactive failed)] end end
each() { |state| ... }
click to toggle source
# File lib/systemd_mon/state.rb, line 36 def each @all_states.each do |state| yield state end end
fail?()
click to toggle source
# File lib/systemd_mon/state.rb, line 46 def fail? any?(&:fail?) end
file_states(type)
click to toggle source
# File lib/systemd_mon/state.rb, line 27 def file_states(type) case type when 'oneshot' [[], []] else [%w(enabled linked-runtime static), %w(disabled)] end end
ok?()
click to toggle source
# File lib/systemd_mon/state.rb, line 42 def ok? all?(&:ok?) end
to_s()
click to toggle source
# File lib/systemd_mon/state.rb, line 50 def to_s @all_states.join(', ') end