Class: Rack::Mount::Analysis::Histogram
- Inherits:
-
Hash
- Object
- Hash
- Rack::Mount::Analysis::Histogram
- Defined in:
- lib/rack/mount/analysis/histogram.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
Instance Method Summary collapse
- #<<(value) ⇒ Object
-
#initialize ⇒ Histogram
constructor
A new instance of Histogram.
- #select_upper ⇒ Object
Constructor Details
#initialize ⇒ Histogram
Returns a new instance of Histogram.
6 7 8 9 |
# File 'lib/rack/mount/analysis/histogram.rb', line 6 def initialize @count = 0 super(0) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
4 5 6 |
# File 'lib/rack/mount/analysis/histogram.rb', line 4 def count @count end |
Instance Method Details
#<<(value) ⇒ Object
11 12 13 14 |
# File 'lib/rack/mount/analysis/histogram.rb', line 11 def <<(value) @count += 1 self[value] += 1 if value end |
#select_upper ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rack/mount/analysis/histogram.rb', line 16 def select_upper values = sort_by { |_, value| value } values.reverse! values = values.select { |_, value| value >= count / size } values.map! { |key, _| key } values end |