Sha256: 7212691c32503af1248d8b57cc536a1aa1fdd4fbddb6cee0a162c5baafc87a01

Contents?: true

Size: 360 Bytes

Versions: 4

Compression:

Stored size: 360 Bytes

Contents

class String
  unless method_defined?(:titleize)
    def titleize
      gsub("_", " ").gsub(/\b('?[a-z])/){$1.upcase}
    end
  end

  unless method_defined?(:underscore)
    def underscore
      gsub(/::/, '/').
        gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
        gsub(/([a-z\d])([A-Z])/,'\1_\2').
        gsub("-", "_").
        downcase
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
any_view-0.2.3 ./lib/any_view/core_ext/string.rb
any_view-0.2.2 ./lib/any_view/core_ext/string.rb
any_view-0.2.0 /Users/dneighman/Projects/any_view/lib/any_view/core_ext/string.rb
any_view-0.1.0 lib/any_view/core_ext/string.rb