class Eye::Process::StatesHistory

Public Instance Methods

all?(*seq) click to toggle source
# File lib/eye/process/states_history.rb, line 54
def all?(*seq)
  states.all? do |st|
    seq.flatten.include?(st)
  end
end
any?(*seq) click to toggle source
# File lib/eye/process/states_history.rb, line 42
def any?(*seq)
  states.any? do |st|
    seq.flatten.include?(st)
  end
end
end?(*seq) click to toggle source
# File lib/eye/process/states_history.rb, line 36
def end?(*seq)
  str = states * ','
  substr = seq.flatten * ','
  str.end_with?(substr)
end
last_reason() click to toggle source
# File lib/eye/process/states_history.rb, line 22
def last_reason
  last[:reason] rescue nil
end
last_state() click to toggle source
# File lib/eye/process/states_history.rb, line 18
def last_state
  last[:state]
end
last_state_changed_at() click to toggle source
# File lib/eye/process/states_history.rb, line 26
def last_state_changed_at
  Time.at(last[:at])
end
noone?(*seq) click to toggle source
# File lib/eye/process/states_history.rb, line 48
def noone?(*seq)
  !states.all? do |st|
    seq.flatten.include?(st)
  end
end
push(state, reason = nil, tm = Time.now) click to toggle source
Calls superclass method Eye::Utils::Tail#push
# File lib/eye/process/states_history.rb, line 3
def push(state, reason = nil, tm = Time.now)
  super(state: state, at: tm.to_i, reason: reason)
end
seq?(*seq) click to toggle source
# File lib/eye/process/states_history.rb, line 30
def seq?(*seq)
  str = states * ','
  substr = seq.flatten * ','
  str.include?(substr)
end
state_count(state) click to toggle source
# File lib/eye/process/states_history.rb, line 60
def state_count(state)
  states.count do |st|
    st == state
  end
end
states() click to toggle source
# File lib/eye/process/states_history.rb, line 7
def states
  self.map{|c| c[:state] }
end
states_for_period(period, from_time = nil) click to toggle source
# File lib/eye/process/states_history.rb, line 11
def states_for_period(period, from_time = nil)
  tm = Time.now - period
  tm = [tm, from_time].max if from_time
  tm = tm.to_f
  self.select{|s| s[:at] >= tm }.map{|c| c[:state] }
end