Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zachgersh
Created March 25, 2013 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zachgersh/5234464 to your computer and use it in GitHub Desktop.
Save zachgersh/5234464 to your computer and use it in GitHub Desktop.
def translate(phrase)
parts = phrase.split
final_pigs = []
parts.each do |word|
char = word.split(//)
unless char.at(0).match(/[aeiou]/)
new_string = char
until new_string.at(0).match(/[aeio]/)
new_string << new_string.shift
end
final_pigs << new_string.join + "ay"
else
final_pigs << word + "ay"
end
end
final_pigs.join(" ")
end
@jcsalterego
Copy link

My fork and comments here: https://gist.github.com/jcsalterego/5234470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment