Let's say I have a class called
a = Person::User::Base
How can I get only the last subclass called Base .
Base
How do I know how to do this:
a.to_s.split('::').last => "Base"
Is there a better way?
If you are using Rails (ActiveSupport):
a.to_s.demodulize
If you use POR (plain-ol-Ruby), yes, this is your way:
a.to_s.split('::').last