Created
September 8, 2013 15:54
-
-
Save camkidman/6485843 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(string) | |
x = string | |
if x.split.count > 1 | |
new_array = x.split | |
new_array.each do |w| | |
w.to_s | |
if w[0].match(/[aeiou]/) | |
w = w + "ay" | |
elsif w[0] !~ (/[aeiou]/) && w[1] !~ (/[aeiou]/) | |
w[2..-1] + w[0..1] + "ay" | |
elsif w[0] !~ (/[aeiou]/) | |
l = w.slice!(0) | |
w = w + l + "ay" | |
end | |
end | |
new_array.join(' ') | |
else | |
if x[0].match(/[aeiou]/) | |
x = x + "ay" | |
elsif x[0] !~ (/[aeiou]/) && x[1] !~ (/[aeiou]/) | |
x[2..-1] + x[0..1] + "ay" | |
elsif x[0] !~ (/[aeiou]/) | |
l = x.slice!(0) | |
x = x + l + "ay" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment