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?
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.