I hope someone can help with this - I am a Ruby newbie.
In my code I want to decide at runtime which type of object to create,
based on a variable holding the name of the class.
So I have classes Foo and Bar and a string todays_class.
If todays_class = “Foo” I want to say my_obj = Foo.new
if todayS_class = “Bar” then my_obj = Bar.new
Except I’ve got a lot more than two classes and I’d prefer not to use an
if or case statement, so that I don’t need to change the code if I add
another one to the list.
Any suggestions on a neat way to do this?