Class: Compter::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/compter/counter.rb

Instance Method Summary collapse

Instance Method Details

#count_occurrences_of(text, input) ⇒ Object



4
5
6
# File 'lib/compter/counter.rb', line 4

def count_occurrences_of(text, input)
	input.scan(text).size
end

#count_per_identifier(identifiers, input) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/compter/counter.rb', line 8

def count_per_identifier(identifiers, input)
	results = Hash.new

	identifiers.each do |identifier, query|
	  occurrences = 0

	  input.each do |text|
		occurrences += count_occurrences_of(query, text)
	  end

	  results[identifier] = occurrences
	end

	results
end