Project

General

Profile

Actions

Feature #5628

closed

Module#basename

Added by trans (Thomas Sawyer) about 13 years ago. Updated about 4 years ago.

Status:
Feedback
Target version:
-
[ruby-core:41004]

Description

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
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0