Sha256: 8df80bec4dd45a078465a4a8ee4a2061ee3abfe7434d52acb9a1d8270eb08be0

Contents?: true

Size: 630 Bytes

Versions: 20

Compression:

Stored size: 630 Bytes

Contents

class Class

  # Converts a class name to a unix path
  #   
  #   My::ClassName.unix_path => "/my/class_name"
  #
  # Inspired by facet/string/underscore.
  #
  def unix_path
    '/' + name.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').gsub('::','/').downcase
  end
end

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCClass < Test::Unit::TestCase

    def test_method_name
      assert_equal( Test::Unit::TestCase.unix_path, '/test/unit/test_case' )
    end

  end

=end
                                 

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
facets-1.2.0 lib/facets/core/class/unix_path.rb
facets-1.1.0 lib/facet/class/unix_path.rb
facets-1.2.1 lib/facets/core/class/unix_path.rb
facets-1.3.0 lib/facets/core/class/unix_path.rb
facets-1.3.1 lib/facets/core/class/unix_path.rb
facets-1.3.2 lib/facets/core/class/unix_path.rb
facets-1.3.3 lib/facets/core/class/unix_path.rb
facets-1.4.2 lib/facets/core/class/unix_path.rb
facets-1.4.0 lib/facets/core/class/unix_path.rb
facets-1.4.1 lib/facets/core/class/unix_path.rb
facets-1.4.3 lib/facets/core/class/unix_path.rb
facets-1.4.4 lib/facets/core/class/unix_path.rb
facets-1.4.5 lib/facets/core/class/unix_path.rb
facets-1.7.30 lib/facets/core/class/unix_path.rb
facets-1.7.0 lib/facets/core/class/unix_path.rb
facets-1.7.38 lib/facets/core/class/unix_path.rb
facets-1.7.46 lib/facets/core/class/unix_path.rb
facets-1.8.0 lib/facets/core/class/unix_path.rb
facets-1.8.20 lib/facets/core/class/unix_path.rb
facets-1.8.8 lib/facets/core/class/unix_path.rb