Module: Dolarblue::Inflector

Extended by:
Inflector
Included in:
Inflector
Defined in:
lib/dolarblue/inflector.rb

Instance Method Summary collapse

Instance Method Details

#demodulize(path) ⇒ String

Removes the module part from the expression in the string.

Examples:

demodulize('ActiveRecord::CoreExtensions::String::Inflections') # => "Inflections"
demodulize('Inflections')                                       # => "Inflections"

Parameters:

  • path (String)

    the module expression stringified

Returns:

  • (String)

    with the module part removed and the stringified class name only



14
15
16
17
18
19
20
21
# File 'lib/dolarblue/inflector.rb', line 14

def demodulize(path)
  path = path.to_s
  if i = path.rindex('::')
    path[(i+2)..-1]
  else
    path
  end
end