module Thoran::String::ToConst

Public Instance Methods

to_const() click to toggle source
# File lib/Thoran/String/ToConst/to_const.rb, line 28
def to_const
  if self =~ /::/
    constants = self.split('::')
    constant = Object.const_get(constants.first)
    constants = constants.all_but_first
    until constants.empty? do
      constant = constant.const_get(constants.shift)
    end
  else
    constant = Object.const_get(self)
  end
  constant
end
Also aliased as: to_constant
to_constant()
Alias for: to_const