Sha256: fa8e6b8b3c915b730ed51c75d15fbba5cd71538046fe7f6dbe83586713cf0b24

Contents?: true

Size: 491 Bytes

Versions: 7

Compression:

Stored size: 491 Bytes

Contents

class String

  # Converts a (class or module) name to a unix path.
  #
  #   My::CoolClass.name.pathize  #=> "my/cool_class"
  #
  #--
  # Rails definition:
  #
  #    gsub(/__/, '/').
  #    gsub(/::/, '/').
  #    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  #    gsub(/([a-z\d])([A-Z])/,'\1_\2').
  #    tr("-", "_").
  #    downcase
  #++
  def pathize
    gsub(/([A-Z]+)([A-Z])/,'\1_\2').
    gsub(/([a-z])([A-Z])/,'\1_\2').
    gsub('__','/').
    gsub('::','/').
    downcase
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/string/pathize.rb
facets-2.8.3 lib/core/facets/string/pathize.rb
facets-2.8.2 lib/core/facets/string/pathize.rb
facets-2.8.1 lib/core/facets/string/pathize.rb
facets-2.8.0 lib/core/facets/string/pathize.rb
facets-2.7.0 lib/core/facets/string/pathize.rb
facets-2.6.0 lib/core/facets/string/pathize.rb