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-rwgps-0.0.63 lib/bluepill/process_statistics.rb
bluepill-rwgps-0.0.62 lib/bluepill/process_statistics.rb
bluepill-rwgps-0.0.61 lib/bluepill/process_statistics.rb
cloud66-bluepill-0.0.64 lib/bluepill/process_statistics.rb
bluepill-0.0.68 lib/bluepill/process_statistics.rb
bluepill-0.0.67 lib/bluepill/process_statistics.rb
bluepill-rwgps-0.0.60 lib/bluepill/process_statistics.rb
bluepill-0.0.66 lib/bluepill/process_statistics.rb
bluepill-0.0.65 lib/bluepill/process_statistics.rb
bluepill-0.0.64 lib/bluepill/process_statistics.rb
cloud66-bluepill-0.0.63 lib/bluepill/process_statistics.rb
bluepill-0.0.63 lib/bluepill/process_statistics.rb
cloud66-bluepill-0.0.62 lib/bluepill/process_statistics.rb
bluepill-0.0.62 lib/bluepill/process_statistics.rb
bluepill-0.0.61 lib/bluepill/process_statistics.rb
kostya-bluepill-0.0.60.3 lib/bluepill/process_statistics.rb
kostya-bluepill-0.0.60.2 lib/bluepill/process_statistics.rb
kostya-bluepill-0.0.60.1 lib/bluepill/process_statistics.rb
skalar-bluepill-0.0.60.1 lib/bluepill/process_statistics.rb
bluepill-0.0.60 lib/bluepill/process_statistics.rb