factory-method

How to create a "class cluster" (factory class with instances of concrete subclasses) in Ruby?

I would like to create an abstract class which will create concrete instances depending on initialization parameter. Example: class SomethingGeneric def self.new(type, arg) class_name = "#{type.capitalize}Something" if obj.const_defined?(class_name) a_class = obj.const_get(class_name) else raise ArgumentErr...