wordini 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wordini.rb +18 -8
- metadata +1 -1
data/lib/wordini.rb
CHANGED
@@ -1,21 +1,31 @@
|
|
1
1
|
class Wordini
|
2
2
|
|
3
3
|
def self.obfuscate(word_string, words_to_remove)
|
4
|
-
word_string
|
5
|
-
if words_to_remove.include? word
|
6
|
-
"*" * word.length
|
7
|
-
else
|
8
|
-
word
|
9
|
-
end
|
10
|
-
}.join(' ')
|
4
|
+
hide_words(word_string, words_to_remove)
|
11
5
|
end
|
12
6
|
|
13
7
|
def self.report(word_string, search_terms)
|
8
|
+
count_words(word_string, search_terms)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.count_words(word_string, search_terms)
|
14
14
|
word_set = {}
|
15
|
-
|
15
|
+
search_terms.each { |word|
|
16
16
|
count = word_string.split.count(word)
|
17
17
|
word_set[word] = count
|
18
18
|
}
|
19
19
|
word_set
|
20
20
|
end
|
21
|
+
|
22
|
+
def self.hide_words(word_string, words_to_remove)
|
23
|
+
word_string.split.map{ |word|
|
24
|
+
if words_to_remove.include? word
|
25
|
+
"*" * word.length
|
26
|
+
else
|
27
|
+
word
|
28
|
+
end
|
29
|
+
}.join(' ')
|
30
|
+
end
|
21
31
|
end
|