Indy rb

Please accept this!!!
If the ruleset was larger, I’d definitely prefer your solution. If there’s only 3 rules in play for this branch, those, seems more complex than the (ideal but not current) branching statement to me.  


On Thursday, August 14, 2014 at 12:32 AM, janxious wrote:

> In lib/piglatin.rb:
> > + def initialize the_phrase > + self.phrase = the_phrase > + end > + > + def translate > + if phrase.empty? > + nil > + elsif !VOWELS.include? phrase.chars.first > + return "#{phrase[1, 999999]}#{phrase.chars.first}ay"; > + else > + if phrase.chars.last == 'y' > + return "#{phrase}nay"; > + elsif !VOWELS.include? phrase.chars.last > + return "#{phrase}ay"; > + else > + return "#{phrase}yay";  
> here is the general outline of a solution I was thinking about when I saw this:
> ending_map = { ["a", "e", "i", "o", "u"] => "foo", ["c", "q", "r"] => "bar" } thing = "i" ending = ending_map.find { |matchset, _| matchset.include?(thing) }.last  
>  
> I can't tell if it's better.
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/ar3/piglatin-2014-08-11-232511/pull/1/files#r16220867).
>  
>  
>