Method: CoreExt::Inflector#deconstantize
- Defined in:
- lib/core_ext/inflector/methods.rb
#deconstantize(path) ⇒ Object
Removes the rightmost segment from the constant expression in the string.
deconstantize('Net::HTTP') # => "Net"
deconstantize('::Net::HTTP') # => "::Net"
deconstantize('String') # => ""
deconstantize('::String') # => ""
deconstantize('') # => ""
See also #demodulize.
215 216 217 |
# File 'lib/core_ext/inflector/methods.rb', line 215 def deconstantize(path) path.to_s[0, path.rindex('::') || 0] # implementation based on the one in facets' Module#spacename end |