Issue #5628 has been updated by Thomas Sawyer.


@Andrew File::basename is a class method, where as Module#basename is an instance method, so there isn't really any "polymorphic confliction".

I think we'd also be hard pressed to find a better name. I've thought about it quite a bit. And nothing else seems to fit. Ironically #firstname makes the most semantic sense for English speakers. Since Ruby is Japanese in origin, then #lastname is a fun option to confound Americans ;) 

I think #basename is best b/c there is a common correspondence between files and classes, eg. `lib/foo/some_class` will usually contain `Foo::SomeClass`. There is also `Pathname#basename`.

----------------------------------------
Feature #5628: Module#basename
http://redmine.ruby-lang.org/issues/5628

Author: Thomas Sawyer
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 1.9.4


Something I use fairly often:

    some_module.name.split("::").last

It's useful for things like factory methods. It would be much nicer if we had:

    class Module
      def basename
        name.split("::").last
      end
    end




-- 
http://redmine.ruby-lang.org