Class: EventedBluepill::ProcessStatistics

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(size = 10) ⇒ ProcessStatistics

possibly persist this data.



10
11
12
# File 'lib/evented_bluepill/process_statistics.rb', line 10

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

Instance Method Details

#record_event(event, reason) ⇒ Object



14
15
16
# File 'lib/evented_bluepill/process_statistics.rb', line 14

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

#to_sObject



18
19
20
21
22
23
24
# File 'lib/evented_bluepill/process_statistics.rb', line 18

def to_s
  str = @events.reverse.collect do |(event, reason, time)|
    str << "  #{event} at #{time.strftime(STRFTIME)} - #{reason || "unspecified"}"
  end.join("\n")

  "event history:\n#{str}"
end