Sha256: a4b1fb7b8f77beca1f3692604191be0f7355a58c74c58ed645f5153019a5bd90

Contents?: true

Size: 595 Bytes

Versions: 6

Compression:

Stored size: 595 Bytes

Contents

class String

  # Converts a camelcase name (e.g. class or module name) to a unix path.
  #
  #   "ExamplePathize".pathize           #=> "example_pathize"
  #   "ExamplePathize::Example".pathize  #=> "example_pathize/example"
  #
  def pathize
    gsub(/([A-Z]+)([A-Z])/,'\1_\2').
    gsub(/([a-z])([A-Z])/,'\1_\2').
    gsub('__','/').
    gsub('::','/').
    downcase
  end

  #--
  # Rails definition ...
  #
  #    gsub(/__/, '/').
  #    gsub(/::/, '/').
  #    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  #    gsub(/([a-z\d])([A-Z])/,'\1_\2').
  #    tr("-", "_").
  #    downcase
  #++

end

Version data entries

6 entries across 5 versions & 1 rubygems

Version Path
facets-2.9.2 lib/core/facets/string/pathize.rb
facets-2.9.2 src/core/facets/string/pathize.rb
facets-2.9.1 lib/core/facets/string/pathize.rb
facets-2.9.0 lib/core/facets/string/pathize.rb
facets-2.9.0.pre.2 lib/core/facets/string/pathize.rb
facets-2.9.0.pre.1 lib/core/facets/string/pathize.rb