Class: Translator
- Inherits:
-
Object
- Object
- Translator
- Defined in:
- lib/catchat/translator.rb
Constant Summary collapse
- @@dictionary =
DICTIONARY
Class Method Summary collapse
-
.catify_letter(letter) ⇒ Object
Human To Cat.
- .catify_passage(passage) ⇒ Object
- .catify_word(word) ⇒ Object
-
.humanize_letter(letter) ⇒ Object
Cat To Human.
- .humanize_passage(passage) ⇒ Object
- .humanize_word(word) ⇒ Object
Class Method Details
.catify_letter(letter) ⇒ Object
Human To Cat
8 9 10 |
# File 'lib/catchat/translator.rb', line 8 def self.catify_letter(letter) return @@dictionary[letter] end |
.catify_passage(passage) ⇒ Object
16 17 18 |
# File 'lib/catchat/translator.rb', line 16 def self.catify_passage(passage) passage.downcase.split(' ').map{|w| Translator.catify_word(w)}.join(' ') end |
.catify_word(word) ⇒ Object
12 13 14 |
# File 'lib/catchat/translator.rb', line 12 def self.catify_word(word) word.split('').map{|l| Translator.catify_letter(l)}.join(' ') end |
.humanize_letter(letter) ⇒ Object
Cat To Human
21 22 23 |
# File 'lib/catchat/translator.rb', line 21 def self.humanize_letter(letter) return @@dictionary.key(letter) end |
.humanize_passage(passage) ⇒ Object
29 30 31 |
# File 'lib/catchat/translator.rb', line 29 def self.humanize_passage(passage) passage.downcase.split(' ').map{|w| Translator.humanize_word(w)}.join(' ') end |
.humanize_word(word) ⇒ Object
25 26 27 |
# File 'lib/catchat/translator.rb', line 25 def self.humanize_word(word) word.split(' ').map{|l| Translator.humanize_letter(l)}.join('') end |