At work I need to process different bits of information stored in csv  
format. I use OpenStruct modified to create new propertied from  
strings that I read from the file headers. I don't have the code  
here, but can get it if anyone is interested.

I find this method very useful as then I can work with the properties  
I require, but the code doesn't fall over when the format of the  
files changes (not that that would happen without anyone telling me  
first... ;-) )

Cheers,
Dave


On 17/02/2007, at 12:30 PM, Joe at CodeGear wrote:

> Anyone have an interesting or idiomatic usage of Struct?
>
> Other than the obvious usage for on-the-fly attr reader/writer
> objects, what else can you do with this?
>
> One use case that came to mind was for managing CSV files (esp. w/
> headers).  You could create a Struct for the file, using the header
> row from the file, passing a block to the new method to add a method
> to initialize it based on an array (as returned from the csv reader).
>
> Anyone have a cool usage?
>
> Joe at CodeGear
>
>