How to create object of class name of which is in text strin

I know what this is about Abstract Factory pattern. But in example at
rubygarden we passing a class to factory and it creates an object from
it.
But how can i pass a text string to factory which will create an object
from it?
In later example: i wish to pass string “Foo” or “Bar” not Foo or Bar.

------ From rubygarden library of patterns ------
class Foo; end
class Bar; end

Here is the use of the Abstract Factory pattern

def create_something( factory )
new_object = factory.new
puts “created a new #{new_object.class} with a factory”
end

Here we select a factory to use

create_something( Foo )
create_something( Bar )

Running the code above results in the output:
created a Foo with a factory
created a Bar with a factory

On 01/12/06, xTRiM [email protected] wrote:

class Bar; end

Running the code above results in the output:
created a Foo with a factory
created a Bar with a factory

create_something(Kernel.const_get(“Foo”))

Farrel

create_something(Kernel.const_get(“Foo”))

Farrel

Thanks a lot, Farrel!