On Thu, 31 May 2001  23:50:18 +0900, Jim Freeze wrote:
> Hi all:
> 
> I am writing an app and could use a little advice from
> some of you oop gurus.
> 
> A broad statement of the problem is this:
>   I have an object that contains geometrical objects and need
>   a way to write a description of those objects in different
>   formats. Although not the exact case, you can consider
>   this task similar to a drawing program where an object
>   holds a list of drawing objects and it needs to be able to
>   write these out in various formats, such as postscript or xfig.
> 
> I know there are lots of ways to do this, including writing
> the objects out in a meta format and give all the other
> export classes the ability to parse the meta format.
> 
> I am hoping someone has done something like this and has
> a clever way to do this in Ruby. A class pattern would be
> nice.

. structure the geometrical objects with a composite pattern, use a
  builder pattern to construct the composite.
. use a visitor or a builder pattern to transform the composite into
  various representations.

The composite example at

	http://www.xs4all.nl/~hipster/lib/ruby/composite

shows how to combine a composite and a visitor. See the GangOfFour
book, or see http://rampages.onramp.net/~huston/dp/patterns.html.
These basic patterns fit your problem nicely.

	hth,
	Michel