Module: Spanglify
- Defined in:
- lib/spanglify.rb,
lib/spanglify/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Class Method Details
.process(str) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/spanglify.rb', line 4 def self.process(str) #commonly interchanged English to Spanish words and phrases to_swap = { "are you" => "estás", "very" => "muy", "but" => "pero", "i like" => "me gusta", "party" => "fiesta", "with" => "con" } to_swap.each do |key, value| #create a capitalized versions of the key and values capitalized_key = key.capitalize capitalized_value = value.capitalize upcase_key = key.upcase upcase_value = value.upcase if str.include? "#{key}" #if the string contains the lowercase version of the English word(s) str.gsub!(key, value) #swap out for the lowercase Spanish version of the word(s) elsif str.include? "#{upcase_key}" #if the string contains the capitalized version of the English word(s) str.gsub!(upcase_key, upcase_value) #swap out for the capitalized version of the Spanish word(s) elsif str.include? "#{capitalized_key}" #if the string contains the uppercase version of the English word(s) str.gsub!(capitalized_key, capitalized_value) #swap out for the uppercase version of the Spanish word(s) end end str #return the spanglified version of the string end |