Sha256: b59b7a7caa992283c603369b57e074e6874b050a6f72521f65cd7192afeca3f6

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

module Bluepill
  class ProcessStatistics
    STRFTIME = '%m/%d/%Y %H:%I:%S'.freeze
    EVENTS_TO_PERSIST = 10

    attr_reader :events

    # possibly persist this data.
    def initialize
      @events = Util::RotationalArray.new(EVENTS_TO_PERSIST)
    end

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bluepill-0.0.69 lib/bluepill/process_statistics.rb