Class: SystemdMon::StateValue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, timestamp, ok_states = [], failure_states = [])
  self.name = name
  self.value = value
  self.ok_states = ok_states
  self.failure_states = failure_states
  self.timestamp = timestamp
end

Instance Attribute Details

#failure_statesObject

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

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/systemd_mon/state_value.rb', line 3

def name
  @name
end

#ok_statesObject

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

#timestampObject

Returns the value of attribute timestamp.



3
4
5
# File 'lib/systemd_mon/state_value.rb', line 3

def timestamp
  @timestamp
end

#valueObject

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_nameObject



13
14
15
# File 'lib/systemd_mon/state_value.rb', line 13

def display_name
  name.capitalize
end

#fail?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_sObject



37
38
39
# File 'lib/systemd_mon/state_value.rb', line 37

def to_s
  value
end