Class: PigLatin::Translator

Inherits:
Object
  • Object
show all
Defined in:
lib/piggy_latin.rb

Constant Summary collapse

ENDING =

how all the words end

"ay"

Instance Method Summary collapse

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 (options = {:dash => true})
  @dash = options[: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