Skip to content

Instantly share code, notes, and snippets.

@flanger001
Last active June 1, 2018 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flanger001/908c09c6d050d726c2029d57ef2b7455 to your computer and use it in GitHub Desktop.
Save flanger001/908c09c6d050d726c2029d57ef2b7455 to your computer and use it in GitHub Desktop.
class String
def rotate_vowels(num = 1)
vowels = "aeiou"
uc_vowels = vowels.upcase
tr(uc_vowels, uc_vowels.chars.rotate(num).join).tr(vowels, vowels.chars.rotate(num).join)
end
end
str = "Hey, I'm gonna need you to come in on Saturday."
str.rotate_vowels
# => "Hiy, O'm gunne niid yua tu cumi on un Setardey."
str.rotate_vowels(2)
# => "Hoy, U'm ganni nood yae ta camo un an Siterdiy."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment