Sha256: 4422f2aa2a87058406376d0ff4a3e6e3b1798492f41674de65ed6f02632028cf

Contents?: true

Size: 581 Bytes

Versions: 1

Compression:

Stored size: 581 Bytes

Contents

class Wordini

	def self.obfuscate(word_string, words_to_remove)
		hide_words(word_string, words_to_remove)
	end

	def self.report(word_string, search_terms)
		count_words(word_string, search_terms)
	end

	private

	def self.count_words(word_string, search_terms)
		word_set = {}
			search_terms.each { |word|
			count = word_string.split.count(word)
			word_set[word] = count
		}
		word_set
	end

	def self.hide_words(word_string, words_to_remove)
		word_string.split.map{ |word| 
		if words_to_remove.include? word
			"*" * word.length
		else
			word
		end
		}.join(' ')
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordini-0.1.2 lib/wordini.rb