#require 'facets/core/module/dirname'
#require 'facets/core/kernel/constant'

class Module

  # Returns the module's container module.
  #
  #   module Example
  #     class Demo
  #     end
  #   end
  #
  #   Demo.modspace    #=> Example
  #
  # See also Module#basename.
  #
  def modspace
    eval self.name[ 0...self.name.rindex( '::' ) ]
  end

end


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

  require 'test/unit'

  class TCModule < Test::Unit::TestCase

    def test_modspace
      assert_equal( Test::Unit, Test::Unit::TestCase.modspace )
      assert_equal( ::Test::Unit, ::Test::Unit::TestCase.modspace )
    end

  end

=end
