Class: Heuristics::Tester::Frequency

Inherits:
Object
  • Object
show all
Defined in:
lib/heuristics/tester.rb

Instance Method Summary collapse

Constructor Details

#initializeFrequency

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

#listObject



27
28
29
# File 'lib/heuristics/tester.rb', line 27

def list
	Hash[@storage.sort_by{|key, value| value }.reverse]
end