Sha256: ddcc0ad166a23e8d7b135aa63fd0ccc61fcb02af1e6fd6da971a838610770db1

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 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.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

2 entries across 2 versions & 2 rubygems

Version Path
ryansch-bluepill-0.0.53 lib/bluepill/process_statistics.rb
bluepill-0.0.51 lib/bluepill/process_statistics.rb