gibber 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gibber/version.rb +1 -1
- data/lib/gibber.rb +2 -2
- data/test/tests.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0847b7e884e31eb1e706bf2bb51fa6fd0bb77500
|
4
|
+
data.tar.gz: 187bc73dff3098aeb1177578836741b566f050e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16207dca51a54af5defe47877adf6f5d8334761ceee17ae94482973ed538bf55cd83a3051a6dada89c7ddfc870b43fddfd66640bf83a9b9f35b9718bf37537cc
|
7
|
+
data.tar.gz: efac5556d8aecdb7c78d5433e43155a29be823ccc7ba954466aa83c8887f13aa8f5d802299534ceda6a2c012ae5fb08befcaa24387042d39b395c318d35908ac
|
data/lib/gibber/version.rb
CHANGED
data/lib/gibber.rb
CHANGED
@@ -14,14 +14,14 @@ class Gibber
|
|
14
14
|
private
|
15
15
|
|
16
16
|
# recursive if missing translation
|
17
|
-
def replace_word(word)
|
17
|
+
def replace_word(word, tries_left=100)
|
18
18
|
return word if blank?(word) || numeric?(word) || !wordy?(word)
|
19
19
|
|
20
20
|
possible_keys = keys_within_margin_for_word(word)
|
21
21
|
if translation = translation_at_keys(*possible_keys)
|
22
22
|
conditional_capitalize(word, translation)
|
23
23
|
else
|
24
|
-
replace_word(word[0..-2])
|
24
|
+
tries_left == 0 ? ['I','V','X'].sample : replace_word(word[0..-2], tries_left - 1)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/test/tests.rb
CHANGED