Sha256: 262f09d6325a739c29666a32d3f403bc73fb7a0a3aa8e8436d0deb5a5f99fa2f

Contents?: true

Size: 599 Bytes

Versions: 28

Compression:

Stored size: 599 Bytes

Contents

# -*- encoding: utf-8 -*-
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

28 entries across 28 versions & 5 rubygems

Version Path
bluepill-0.0.59 lib/bluepill/process_statistics.rb
bluepill-0.0.58 lib/bluepill/process_statistics.rb
bluepill-0.0.57 lib/bluepill/process_statistics.rb
bluepill-0.0.56 lib/bluepill/process_statistics.rb
bluepill-0.0.55 lib/bluepill/process_statistics.rb
bluepill-0.0.54 lib/bluepill/process_statistics.rb
bluepill-0.0.53 lib/bluepill/process_statistics.rb
bluepill-0.0.52 lib/bluepill/process_statistics.rb