Getting class name without module

Is there a method available to get only the class name, without getting
the module name prior to it? Alternatively, to get the class name within
the current name space context?

For example, self.class could return something like this:
MyModule::MyClass
(I would like to only get the “MyClass” part.)

Or do I have to resort to string manipulation/regexps?

Best regards,

Jari W.

On Feb 12, 2008, at 13:05 , Jari W. wrote:

Is there a method available to get only the class name, without
getting the module name prior to it? Alternatively, to get the class
name within the current name space context?

For example, self.class could return something like this:
MyModule::MyClass
(I would like to only get the “MyClass” part.)

Or do I have to resort to string manipulation/regexps?

Indeed, you do it by hand, something like this:

name.split('::').last || ''

– fxn