Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def translate(words)
- a = words.split(" ").map do |word|
- if wordpigtranslated(word)
- end
- a.join(" ")
- end
- def pigtranslated(word)
- vowels = %w{a e i o u}
- if vowels.include?(word[0])
- p "#{word}ay"
- else
- phoneme = 0
- until vowels.include?(word[phoneme])
- phoneme += 1
- end
- if ((word[phoneme-1] == 'q') || (word[phoneme-1] == 'Q'))
- phoneme += 1
- end
- "#{word[phoneme..-1]}#{word[0...phoneme]}ay"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement