lib/wordini.rb in wordini-0.1.1 vs lib/wordini.rb in wordini-0.1.2
- old
+ new
@@ -1,21 +1,31 @@
class Wordini
def self.obfuscate(word_string, words_to_remove)
- word_string.split.map{ |word|
- if words_to_remove.include? word
- "*" * word.length
- else
- word
- end
- }.join(' ')
+ 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|
+ 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
\ No newline at end of file