Class: Procview::Stats
- Inherits:
-
Array
- Object
- Array
- Procview::Stats
- Defined in:
- lib/procview/stats.rb
Constant Summary collapse
- TYPE =
{ other: 0, wait: 1, read: 2, write: 3 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.new ⇒ Object
32 33 34 |
# File 'lib/procview/stats.rb', line 32 def self.new super(4, 0.0) end |
Instance Method Details
#acc!(type, duration) ⇒ Object
44 45 46 |
# File 'lib/procview/stats.rb', line 44 def acc! type, duration self[TYPE[type]] += duration end |
#add!(other) ⇒ Object
35 36 37 |
# File 'lib/procview/stats.rb', line 35 def add!(other) self.map!.with_index{|t,i| t += other[i]} end |
#scale!(other) ⇒ Object
38 39 40 |
# File 'lib/procview/stats.rb', line 38 def scale!(other) self.map!{|t| t *= other} end |
#sum ⇒ Object
41 42 43 |
# File 'lib/procview/stats.rb', line 41 def sum self.reduce(:+) end |