Skip to content

Instantly share code, notes, and snippets.

@sdanko11
Created December 3, 2013 19:08
Show Gist options
  • Select an option

  • Save sdanko11/7775575 to your computer and use it in GitHub Desktop.

Select an option

Save sdanko11/7775575 to your computer and use it in GitHub Desktop.
Pig Latin Translation
class PigLatinTranslation
attr_reader :phrase
def initialize(phrase)
@phrase = phrase
@words_in_phrase = []
end
def translate
starts_with_vowel?
end
def words
@words_in_phrase = @phrase.split(' ')
end
private
def starts_with_vowel?
@words_in_phrase.each do |word|
if word.start_with?('a','e','i','o','u')
print "#{word}way "
else
first_letter = word[0]
word.slice!(0)
print "#{word}#{first_letter.downcase}ay "
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment