Class: TextSearch::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/text_search/base.rb

Class Method Summary collapse

Class Method Details

.counter(text, words) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/text_search/base.rb', line 3

def self.counter(text, words)
	results = []
	hash = Hash.new

	words.each do |word|
		hash[word] = text.scan(/#{word}/).size
		results.push(hash)
		hash = Hash.new
	end
	return results
end

.words(text) ⇒ Object



15
16
17
# File 'lib/text_search/base.rb', line 15

def self.words(text)
	text.split(/\W+/)
end