概要
String#titleize
詳細
String#titleize について
String#titleize
文字列を区切り文字ごとに先頭大文字にする。
サンプル
# encoding: utf-8 require 'active_support/core_ext/string/inflections' require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS 'CamelCase'.titleize 'snake_lower_case'.titleize 'SNAKE_UPPER_CASE'.titleize 'spaced lower case'.titleize 'SPACED UPPER CASE'.titleize 'SomeModule::SomeClass'.titleize EOS __END__ ・下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
'CamelCase'.titleize # => "Camel Case" 'snake_lower_case'.titleize # => "Snake Lower Case" 'SNAKE_UPPER_CASE'.titleize # => "Snake Upper Case" 'spaced lower case'.titleize # => "Spaced Lower Case" 'SPACED UPPER CASE'.titleize # => "Spaced Upper Case" 'SomeModule::SomeClass'.titleize # => "Some Module/Some Class"