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.

Revisions

  1. Jdtanacredi created this gist Aug 2, 2013.
    26 changes: 26 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    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