Sha256: 72468548f7527bbab83626d5ea251389e71cad114076c46af7a32bc56c01fd08

Contents?: true

Size: 636 Bytes

Versions: 5

Compression:

Stored size: 636 Bytes

Contents

class Dolarblue
  module Inflector
    extend self

    # Removes the module part from the expression in the string.
    #
    # @param path [String] the module expression stringified
    #
    # @example
    #   demodulize('ActiveRecord::CoreExtensions::String::Inflections') # => "Inflections"
    #   demodulize('Inflections')                                       # => "Inflections"
    #
    # @return [String] with the module part removed and the stringified class name only
    def demodulize(path)
      path = path.to_s
      if i = path.rindex('::')
        path[(i+2)..-1]
      else
        path
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dolarblue-0.6.0 lib/dolarblue/inflector.rb
dolarblue-0.5.2 lib/dolarblue/inflector.rb
dolarblue-0.5.1 lib/dolarblue/inflector.rb
dolarblue-0.5.0 lib/dolarblue/inflector.rb
dolarblue-0.4.0 lib/dolarblue/inflector.rb