Created
August 2, 2013 01:15
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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