class TextSearch::Base

Public Class Methods

counter(text, words) click to toggle source
# 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) click to toggle source
# File lib/text_search/base.rb, line 15
def self.words(text)
        text.split(/\W+/)
end