Class: NetworkResiliency::PowerStats
- Inherits:
-
Object
- Object
- NetworkResiliency::PowerStats
- Defined in:
- lib/network_resiliency/power_stats.rb
Constant Summary collapse
- MIN_VALUE =
1- LOCK =
Thread::Mutex.new
- STATS =
{}
Instance Attribute Summary collapse
-
#n ⇒ Object
readonly
Returns the value of attribute n.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(value) ⇒ Object
-
#initialize(values = []) ⇒ PowerStats
constructor
A new instance of PowerStats.
- #merge(other) ⇒ Object (also: #+)
- #p99 ⇒ Object
Constructor Details
#initialize(values = []) ⇒ PowerStats
Returns a new instance of PowerStats.
33 34 35 36 37 38 |
# File 'lib/network_resiliency/power_stats.rb', line 33 def initialize(values = []) @lock = Thread::Mutex.new reset values.each {|x| add(x) } end |
Instance Attribute Details
#n ⇒ Object (readonly)
Returns the value of attribute n.
11 12 13 |
# File 'lib/network_resiliency/power_stats.rb', line 11 def n @n end |
Class Method Details
.[](key) ⇒ Object
14 15 16 |
# File 'lib/network_resiliency/power_stats.rb', line 14 def [](key) LOCK.synchronize { STATS[key] ||= new } end |
.reset ⇒ Object
18 19 20 |
# File 'lib/network_resiliency/power_stats.rb', line 18 def reset LOCK.synchronize { STATS.clear } end |
Instance Method Details
#<<(value) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/network_resiliency/power_stats.rb', line 40 def <<(value) case value when Array value.each {|x| add(x) } when self.class merge!(value) else add(value) end self end |
#merge(other) ⇒ Object Also known as: +
90 91 92 |
# File 'lib/network_resiliency/power_stats.rb', line 90 def merge(other) dup.merge!(other) end |
#p99 ⇒ Object
86 87 88 |
# File 'lib/network_resiliency/power_stats.rb', line 86 def p99 percentile(99) end |