From: Pa Per Date: 2006-10-26T17:19:14+09:00 Subject: Beginner would like help with oo-modelling 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 subdivisions. So, let's say the script has received the following data: unit, length label every nth unit lines: 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 and width. 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, hash? And where should the methods be implemented? It's probably good to have the ruler assemble itself when created, by just passing all the properties. 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 of view.. thanks, paper -- Posted via http://www.ruby-forum.com/.