Sha256: 6af5149acf0cac8c2390f64fbb5c2cac9e62c67f86c344733bac4744950f1957

Contents?: true

Size: 537 Bytes

Versions: 4

Compression:

Stored size: 537 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.reverse.collect do |(event, reason, time)|
        str << "  #{event} at #{time.strftime(STRFTIME)} - #{reason || "unspecified"}"
      end.join("\n")

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bluepill-0.0.50 lib/bluepill/process_statistics.rb
bluepill-0.0.49 lib/bluepill/process_statistics.rb
bluepill-0.0.48 lib/bluepill/process_statistics.rb
bluepill-0.0.47 lib/bluepill/process_statistics.rb