Skip to content

Instantly share code, notes, and snippets.

@camkidman
Created September 27, 2013 20:54
Show Gist options
  • Save camkidman/6734990 to your computer and use it in GitHub Desktop.
Save camkidman/6734990 to your computer and use it in GitHub Desktop.
def translate(string)
x = string
vowels = (/[aeiou]/)
withq = (/[aeio]/)
splitskies = x.split
if x =~ (/[qu]/)
vowels = withq
end
if splitskies.size > 1
splitskies.map! do |w|
if w[0] =~ vowels
w = w + "ay"
elsif w[0] !~ vowels && w[1] !~ vowels && w[2] !~ vowels
w = w[3..-1] + w[0..2] + "ay"
elsif w[0] !~ vowels && w[1] !~ vowels
w = w[2..-1] + w[0..1] + "ay"
elsif w[0] !~ vowels
w = w[1..-1] + w[0] + 'ay'
end
end
else
if x[0] =~ vowels
x = x + "ay"
elsif x[0] !~ vowels && x[1] !~ vowels && x[2] !~ vowels
x = x[3..-1] + x[0..2] + "ay"
elsif x[0] !~ vowels && x[1] !~ vowels
x = x[2..-1] + x[0..1] + "ay"
elsif x[0] !~ vowels
l = x.slice!(0)
x = x + l + "ay"
end
end
return splitskies.join(' ') if splitskies.size > 1
return x
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment