def titleize(string)
string.split(\" \").map {|word| word.capitalize}.join(\" \")
end
This titleizes every single word, but how do I capture cert
This is pretty straightforward, just add a condition when you call captalize
:
$nocaps = ['Jack', 'Jill']
def titleize(string)
string.split(" ").map {|word| word.capitalize unless $nocaps.include?(word)}.join(" ")
end
The global variables are contrived for this example, it would probably be an instance variable in your real application.