I’m new to ruby and basically oop as well, but based on what I’ve seen
so far, ruby seems the way to understand and learn oop.
Now, I would like to write a cute little script that generates a ruler
in svg (or maybe ps, pdf as well).
Of course, it should do that in a way that lets the user pass
parameters, specifically a varying number and properties of
So, let’s say the script has received the following data:
label every nth unit
bold and long every unit
normal and medium every 0.5 units
thin and short every 0.1 units
Now, let’s model the object(s):
Should I split everything up into as little/independent ‘units’ as
possible? I would think so.
So a /ruler/ class consists of several /line/ and /label/ objects. Each
instance of line contains a position (relative to some origin), length
(alternatively, the second point [pair of coords] of the line), color
It could be similar with the labels.
Then, the /ruler/ class stores a number of lines and labels.
But how do they get there, and how are they ‘ordered’?
As each kind of line should later be put into a different group (so
manual editing of the SVG is easy) how do I store them? In an array,
And where should the methods be implemented? It’s probably good to have
the ruler assemble itself when created, by just passing all the
And then lateron just using a method that returns the SVG code.
So basically my problem comes down to this:
How do I store the /line/ objects, so that calculation is easy
(conflict: all types of line would be placed at 1 metric_unit for the
parameters given above) and iteration over the several kinds of lines
(for creating groups) is easy as well?
Feedback would be greatly appreciated, it all seems a bit fuzzy now, but
I hope the situation clarifies itself with some input and other points