Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleaned up pig latin.

  • Loading branch information...
commit 7cf81e9d0f059ece31e19ac5a4790c04c241aa4c 1 parent f27f4cb
@mspwong authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 app/models/why_nots/pig_latin.rb
View
8 app/models/why_nots/pig_latin.rb
@@ -3,13 +3,15 @@ class WhyNots::PigLatin
def self.translate(text)
text.split(" ").inject("") do |memo, token|
word = token.downcase.gsub(/[^a-z ]/, '')
- pig_latin_ending = "ay "
- pig_latin_word = word[1, token.length] << token.first << pig_latin_ending
+ pig_latin_word = word[1, token.length] << token.first << SUFFIX
pig_latin_word.capitalize! if token.first == token.first.capitalize
- punctuations = token[pig_latin_word.length-pig_latin_ending.length, token.length]
+ punctuations = token[pig_latin_word.length-SUFFIX.length, token.length]
pig_latin_word.chop! << punctuations unless punctuations.blank?
memo << pig_latin_word
end.strip
end
+private
+ SUFFIX = "ay "
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.