Class: PigLatin::Translator
- Inherits:
-
Object
- Object
- PigLatin::Translator
- Defined in:
- lib/piggy_latin.rb
Constant Summary collapse
- ENDING =
how all the words end
"ay"
Instance Method Summary collapse
-
#initialize(options = {:dash => true}) ⇒ Translator
constructor
A new instance of Translator.
- #translate(phrase) ⇒ Object
Constructor Details
#initialize(options = {:dash => true}) ⇒ Translator
Returns a new instance of Translator.
7 8 9 |
# File 'lib/piggy_latin.rb', line 7 def initialize ( = {:dash => true}) @dash = [:dash] end |
Instance Method Details
#translate(phrase) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/piggy_latin.rb', line 11 def translate (phrase) sentences = phrase.split(".") translated_sentences = sentences.map do |sentence| translation(sentence) + "." end translated_sentences.join(" ") end |