Class: SystemdMon::State
- Inherits:
-
Object
- Object
- SystemdMon::State
- Includes:
- Enumerable
- Defined in:
- lib/systemd_mon/state.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#all_states ⇒ Object
readonly
Returns the value of attribute all_states.
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
-
#sub ⇒ Object
readonly
Returns the value of attribute sub.
-
#unit_file ⇒ Object
readonly
Returns the value of attribute unit_file.
Instance Method Summary collapse
- #each ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(active, sub, loaded, unit_file) ⇒ State
constructor
A new instance of State.
- #ok? ⇒ Boolean
Constructor Details
#initialize(active, sub, loaded, unit_file) ⇒ State
Returns a new instance of State.
9 10 11 12 13 14 15 16 |
# File 'lib/systemd_mon/state.rb', line 9 def initialize(active, sub, loaded, unit_file) = Time.now @active = StateValue.new("active", active, , %w(active), %w(inactive)) @sub = StateValue.new("status", sub, ) @loaded = StateValue.new("loaded", loaded, , %w(loaded)) @unit_file = StateValue.new("file", unit_file, , %w(enabled), %w(disabled)) @all_states = [@active, @sub, @loaded, @unit_file] end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
7 8 9 |
# File 'lib/systemd_mon/state.rb', line 7 def active @active end |
#all_states ⇒ Object (readonly)
Returns the value of attribute all_states.
7 8 9 |
# File 'lib/systemd_mon/state.rb', line 7 def all_states @all_states end |
#loaded ⇒ Object (readonly)
Returns the value of attribute loaded.
7 8 9 |
# File 'lib/systemd_mon/state.rb', line 7 def loaded @loaded end |
#sub ⇒ Object (readonly)
Returns the value of attribute sub.
7 8 9 |
# File 'lib/systemd_mon/state.rb', line 7 def sub @sub end |
#unit_file ⇒ Object (readonly)
Returns the value of attribute unit_file.
7 8 9 |
# File 'lib/systemd_mon/state.rb', line 7 def unit_file @unit_file end |
Instance Method Details
#each ⇒ Object
18 19 20 21 22 |
# File 'lib/systemd_mon/state.rb', line 18 def each @all_states.each do |state| yield state end end |
#fail? ⇒ Boolean
28 29 30 |
# File 'lib/systemd_mon/state.rb', line 28 def fail? any?(&:fail?) end |
#ok? ⇒ Boolean
24 25 26 |
# File 'lib/systemd_mon/state.rb', line 24 def ok? all?(&:ok?) end |