Created
March 25, 2013 01:59
-
-
Save zachgersh/5234464 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My fork and comments here: https://gist.github.com/jcsalterego/5234470