On Apr 11, 2005, at 4:56 PM, Claus Spitzer wrote:

> Greetings!
> A friend of mine has recently started using Ruby, and has run into a
> little problem. He is trying to create different objects depending on
> the contents of a string. His intuition is to use factory design for
> this, and he'd like to know if there is a Ruby Way to do this.

Generally, Ruby makes this kind of design trivial with the fact that 
classes are objects.  Just pass the class object, it's a free factory!  
Here's an example:

	class PrinterA
		def print_something_very_cool
			puts "Using PrinterA!"
		end	
	end

	class PrinterB
		def print_something_very_cool
			puts "Using PrinterB!"
		end	
	end

	def engage_printer( printer )
		p = printer.new
		p.print_something_very_cool
	end

	engage_printer PrinterA
	engage_printer PrinterB

Hope that helps.

James Edward Gray II