Sha256: d7239d810a4a3746a8ea29c2ed10ca3104bc9df7685dcfba66aa317959f4f6a9

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

class Class

  # Converts a class name to a unix path
  #   
  #   My::ClassName.unix_path => "/my/class_name"
  #
  def unix_path # inspired by facet/string/underscore
    '/' + 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.method_name, '/test/unit/test_case' )
    end

  end

=end
                                 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.0.3 packages/core/lib/facet/class/unix_path.rb