Skip to content

Instantly share code, notes, and snippets.

@Jdtanacredi
Created August 2, 2013 01:15
Show Gist options
  • Select an option

  • Save Jdtanacredi/6136794 to your computer and use it in GitHub Desktop.

Select an option

Save Jdtanacredi/6136794 to your computer and use it in GitHub Desktop.
This is a pig latin converter homework assignment I've been working on.
def translate pigLatin
# difference between .. & ... again? //CHECKED
alphabet = ('a'..'z').to_a
# easiest method, make array? //CHECKED
vowel = %w[a e i o u]
# %w foo bar / "word array"
consonant = alphabet - vowel
#use if else/if
#vowel
if vowel.include?(pigLatin[0])
pigLatin + 'ay'
#2 consonants
elsif consonant.include?(pigLatin[0]) && consonant.include?(pigLatin[1])
pigLatin[2..-1] + pigLatin[0..1] + 'ay'
elsif consonant.include?(pigLatin[0])
pigLatin[1..-1] + pigLatin[0] + 'ay'
elsif word[0..1] == "qu"
word[2..word.length]+"quay"
elsif word[0..2] == "squ"
word[3..word.length]+"squay"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment