我需要将每个单词的第一个字符变成大写,其余的变成小写......
manufacturer.MFA_BRAND.first.upcase
只是设置第一个字母大写,但我需要这个:
ALFA ROMEO => Alfa Romeo AUDI => Audi BMW => Bmw ONETWO THREE FOUR => Onetwo Three Four
尝试这个:
puts 'one TWO three foUR'.split.map(&:capitalize).join(' ') #=> One Two Three Four
或者
puts 'one TWO three foUR'.split.map(&:capitalize)*' '