Advertisement
Guest User

Untitled

a guest
May 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. def translate(words)
  2. a = words.split(" ").map do |word|
  3. if wordpigtranslated(word)
  4. end
  5. a.join(" ")
  6. end
  7.  
  8. def pigtranslated(word)
  9. vowels = %w{a e i o u}
  10. if vowels.include?(word[0])
  11. p "#{word}ay"
  12. else
  13. phoneme = 0
  14. until vowels.include?(word[phoneme])
  15. phoneme += 1
  16. end
  17.  
  18. if ((word[phoneme-1] == 'q') || (word[phoneme-1] == 'Q'))
  19. phoneme += 1
  20. end
  21.  
  22. "#{word[phoneme..-1]}#{word[0...phoneme]}ay"
  23. end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement