Sha256: 32f17f746365c387a01c632d099875472bc97cf15ab6024839609effc0681303

Contents?: true

Size: 416 Bytes

Versions: 1

Compression:

Stored size: 416 Bytes

Contents

module System

  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
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

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