概要
String#underscore
詳細
String#underscore について
String#underscore
文字列をスネークケースにした結果を受け取る
サンプル
# encoding: utf-8 require 'active_support/core_ext/string/inflections' require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS 'CamelCase'.underscore 'lower'.underscore 'UPPER'.underscore 'SomeModule::SomeClass'.underscore EOS __END__ ・下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
'CamelCase'.underscore # => "camel_case" 'lower'.underscore # => "lower" 'UPPER'.underscore # => "upper" 'SomeModule::SomeClass'.underscore # => "some_module/some_class"