Tim Pease
1/31/2007 9:31:00 PM
On 1/31/07, Gerald Ebberink <g.h.p.ebberink@nclr.nl> wrote:
>
> Well here comes the big picture. I have a class contains some data and
> amongst other things can generate graphs. What I would like to do is to
> place these graphs in a bunch of files which have unique names (otherwise I
> end up with always the last graph). Since only the variable (and the data)
> are different amongst the instances I wonder how I could give them meaning
> full names like "20070131 var1 XY.jpg" "20070131 var1 Both.jpg " etc.
>
> Now I did think about giving the var as an option while creating the
> instance, but that doesn't help since it is perfectly possible in the code
> that variable from which the instance is referenced is changed.
>
> Now I come to think of it I could try to overload the = operater to let some
> internal variable be changed when the reference is changed but then I still
> need the name of the variable.
>
When you create an instance of this class that contains all the data,
give it a base filename to use when creating and saving off graphs.
Use an incrementing counter to make sure all the filenames are unique.
If you want to get fancy, you can look at the directory where the file
is to be created ...
File.dirname('path/to/data/filename.graph') #=> 'path/to/data'
and see if there are already files named 'filename.1.graph' etc. That
will give you the number to start using to make sure you don't
overwrite older graphs from previous runs.
Just my thoughts on that one :)
Blessings,
TwP