Class: Bluepill::ProcessStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/bluepill/process_statistics.rb

Constant Summary collapse

STRFTIME =
"%m/%d/%Y %H:%I:%S"

Instance Method Summary collapse

Constructor Details

#initializeProcessStatistics

possibly persist this data.



5
6
7
# File 'lib/bluepill/process_statistics.rb', line 5

def initialize
  @events = Util::RotationalArray.new(10)
end

Instance Method Details

#record_event(event, reason) ⇒ Object



9
10
11
# File 'lib/bluepill/process_statistics.rb', line 9

def record_event(event, reason)
  @events.push([event, reason, Time.now])
end

#to_sObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/bluepill/process_statistics.rb', line 13

def to_s
  str = []
  @events.each do |(event, reason, time)|
    str << "  #{event} at #{time.strftime(STRFTIME)} - #{reason || "unspecified"}"
  end
  if str.size > 0
    str << "event history:"
  end
  str.reverse.join("\n")
end