refactored titlecase.rb to use ternary conditional