lib/facets/module/nesting.rb in facets-2.4.0 vs lib/facets/module/nesting.rb in facets-2.4.1

- old
+ new

@@ -12,73 +12,7 @@ c = mod.const_get(name) ; n << c ; c end return n end - # Returns the module's container module. - # - # module Example - # class Demo - # end - # end - # - # Example::Demo.modspace #=> Example - # - # See also Module#basename. - # - # CREDIT: Trans - - def modspace - space = name[ 0...(name.rindex( '::' ) || 0)] - space.empty? ? Object : eval(space) - end - - # Returns the root name of the module/class. - # - # module Example - # class Demo - # end - # end - # - # Demo.name #=> "Example::Demo" - # Demo.basename #=> "Demo" - # - # For anonymous modules this will provide a basename - # based on Module#inspect. - # - # m = Module.new - # m.inspect #=> "#<Module:0xb7bb0434>" - # m.basename #=> "Module_0xb7bb0434" - # - # CREDIT: Trans - - def basename - if name and not name.empty? - name.gsub(/^.*::/, '') - else - nil #inspect.gsub('#<','').gsub('>','').sub(':', '_') - end - end - - # Returns the name of module's container module. - # - # module Example - # class Demo - # end - # end - # - # Demo.name #=> "Example::Demo" - # Demo.spacename #=> "Example" - # - # This used to be called +dirname+. - # - # See also Module#basename. - # - # CREDIT: Trans - - def spacename - name[0...(name.rindex('::') || 0)] - #name.gsub(/::[^:]*$/, '') - end - end