以下の内容はhttps://tbpgr.hatenablog.com/entry/20140301/1393644157より取得しました。


ActiveSupport | String#constantize

概要

String#constantize

詳細

String#constantize について

String#constantize

文字列から定数を取得する

サンプル

# encoding: utf-8
require 'active_support/core_ext/string/inflections'
require 'tbpgr_utils'

class Hoge
  HIGE = "hige"
end

bulk_puts_eval binding, <<-EOS
'Hoge'.constantize
'Hoge::HIGE'.constantize
EOS

__END__
・下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

'Hoge'.constantize # => Hoge
'Hoge::HIGE'.constantize # => "hige"



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140301/1393644157より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14