Skip to content

Instantly share code, notes, and snippets.

@camkidman
Created September 7, 2013 17:54
Show Gist options
  • Save camkidman/6477716 to your computer and use it in GitHub Desktop.
Save camkidman/6477716 to your computer and use it in GitHub Desktop.
def translate(string)
x = string
if x.split.count > 1
new_array = x.split
new_array.each do |w|
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
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