Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#obfuscate(phrase, buzz_words) ⇒ Object
1 2 3 |
# File 'lib/scramblr.rb', line 1 def obfuscate(phrase, buzz_words) puts phrase.split(/(\s)/).collect{ |word| buzz_words.include?(word) ? '*' * (word.size) : word }.join end |
#report(phrase, buzz_words) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/scramblr.rb', line 5 def report(phrase, buzz_words) word_array = phrase.split(" ") counts = Hash.new{|h,k| h[k] = 0} word_array.each{|v| counts[v] += 1 } counts.select{|k,v| buzz_words.include?(k)} end |