lib/bluepill/process_statistics.rb in bluepill-0.0.46 vs lib/bluepill/process_statistics.rb in bluepill-0.0.47

- old
+ new

@@ -1,24 +1,23 @@ +# -*- encoding: utf-8 -*- module Bluepill - class ProcessStatistics + class ProcessStatistics STRFTIME = "%m/%d/%Y %H:%I:%S" + # possibly persist this data. def initialize @events = Util::RotationalArray.new(10) end def record_event(event, reason) @events.push([event, reason, Time.now]) end def to_s - str = [] - @events.each do |(event, reason, time)| + str = @events.reverse.collect 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.join("\n") + + "event history:\n#{str}" end end end