Class: Bluepill::ProcessStatistics
- Inherits:
-
Object
- Object
- Bluepill::ProcessStatistics
- Defined in:
- lib/bluepill/process_statistics.rb
Constant Summary collapse
- STRFTIME =
'%m/%d/%Y %H:%I:%S'.freeze
- EVENTS_TO_PERSIST =
10
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize ⇒ ProcessStatistics
constructor
possibly persist this data.
- #record_event(event, reason) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ ProcessStatistics
possibly persist this data.
9 10 11 |
# File 'lib/bluepill/process_statistics.rb', line 9 def initialize @events = Util::RotationalArray.new(EVENTS_TO_PERSIST) end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
6 7 8 |
# File 'lib/bluepill/process_statistics.rb', line 6 def events @events end |
Instance Method Details
#record_event(event, reason) ⇒ Object
13 14 15 |
# File 'lib/bluepill/process_statistics.rb', line 13 def record_event(event, reason) events.push([event, reason, Time.now]) end |
#to_s ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/bluepill/process_statistics.rb', line 17 def to_s str = events.reverse.collect do |(event, reason, time)| " #{event} at #{time.strftime(STRFTIME)} - #{reason || 'unspecified'}" end.join("\n") "event history:\n#{str}" end |