Class: Heuristics::Tester::Frequency
- Inherits:
-
Object
- Object
- Heuristics::Tester::Frequency
- Defined in:
- lib/heuristics/tester.rb
Instance Method Summary collapse
- #add(name) ⇒ Object
-
#initialize ⇒ Frequency
constructor
A new instance of Frequency.
- #list ⇒ Object
Constructor Details
#initialize ⇒ Frequency
Returns a new instance of Frequency.
18 19 20 |
# File 'lib/heuristics/tester.rb', line 18 def initialize() @storage = {} end |
Instance Method Details
#add(name) ⇒ Object
22 23 24 25 |
# File 'lib/heuristics/tester.rb', line 22 def add(name) @storage[name] ||= 0 @storage[name] += 1 end |
#list ⇒ Object
27 28 29 |
# File 'lib/heuristics/tester.rb', line 27 def list Hash[@storage.sort_by{|key, value| value }.reverse] end |