Sha256: 66483a3af88a71b557c271a744d93b63d656ebbd476d6f96c9acd943d0a4d772

Contents?: true

Size: 372 Bytes

Versions: 1

Compression:

Stored size: 372 Bytes

Contents

class String

  # converts a camel cased word to an underscored word
  def underscore
    self.gsub(/::/, '/').
        gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
        gsub(/([a-z\d])([A-Z])/,'\1_\2').
        tr("-", "_").
        downcase
  end

  # Gets the constant when it is defined that corresponds to this string
  def classify
    Object.const_get self
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caricature-0.7.7 lib/caricature/core_ext/string.rb