Sha256: b4eb168a46ae2be7ec5ea546b76411add36ffe26380fc43651cb8f2dbff380fe

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

# String Override taken from Rails
class String

  def demodulize
    if i = self.rindex("::")
      self[(i + 2)..-1]
    else
      self
    end
  end

  def underscore
    return self unless /[A-Z-]|::/.match?(self)
    word = self.gsub("::".freeze, "/".freeze)
    word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
    word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
    word.tr!("-".freeze, "_".freeze)
    word.downcase!
    word
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api_ai_wrapper-1.0.5 lib/api_ai_wrapper/extensions/string.rb
api_ai_wrapper-1.0.4 lib/api_ai_wrapper/extensions/string.rb