Sha256: 99fb66f8e09bfeb414be5413d3c38c73d87ccb949f4f3a8e561f272fb1e7c8d7

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

# -*- encoding: utf-8 -*-

module Bluepill
  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 << "  #{event} at #{time.strftime(STRFTIME)} - #{reason || "unspecified"}"
      end
      if str.size > 0
        str << "event history:"
      end
      str.reverse.join("\n")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evented_bluepill-0.0.47 lib/bluepill/process_statistics.rb