From: Yehuda Katz Date: 2011-11-14T14:42:01+09:00 Subject: [ruby-core:41007] Re: [ruby-trunk - Feature #5628][Open] Module#basename --0016e644b91443fc6e04b1ab543d Content-Type: text/plain; charset=ISO-8859-1 Totally agreed. This pattern is fairly common. It would also be nice to have Module#modules or something, such that Foo::Bar would return [Foo, Bar]. Yehuda Katz (ph) 718.877.1325 On Sun, Nov 13, 2011 at 6:17 PM, Thomas Sawyer wrote: > > Issue #5628 has been reported by Thomas Sawyer. > > ---------------------------------------- > 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 > > --0016e644b91443fc6e04b1ab543d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Totally agreed. This pattern is fairly common. It would also be nice to hav= e Module#modules or something, such that Foo::Bar would return [Foo, Bar].<= div>
Yehuda Katz
(ph) 718.877.1325


On Sun, Nov 13, 2011 at 6:17 PM, Thomas = Sawyer <transfi= re@gmail.com> wrote:

Issue #5628 has been reported by Thomas Sawyer.

----------------------------------------
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:

=A0 =A0some_module.name.split("::").last

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

=A0 =A0class Module
=A0 =A0 =A0def basename
=A0 =A0 =A0 =A0name.split("::").last
=A0 =A0 =A0end
=A0 =A0end




--
http://redmine.r= uby-lang.org


--0016e644b91443fc6e04b1ab543d--