Class: Rack::Mount::Analysis::Histogram

Inherits:
Hash
  • Object
show all
Defined in:
lib/rack/mount/analysis/histogram.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHistogram

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

#countObject (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_upperObject



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