What do you use this for?
Sometimes you have an abstract class that models all the common
behavior but
to "complete" the functionality some methods need to be defined/
overridden
in the subclasses. In this situation, instantiating the abstract
class is
an error since it is only the subclasses that are "complete". I just
had
a use for this pattern and I decided to just make #new private:
class Base
class <<self; private :new; end
end
class Derived < Base
class <<self; public :new; end
end
The advantage to this is you can still have common initialization
code in
Base#initialize but it can only be accessed by calling super from
#initialize in a subclass.
It is similar to how Enumerable doesn't make sense as a class because
it isn't complete without #each being defined.