From: benjohn@... Date: 2006-10-26T19:11:27+09:00 Subject: Re: Beginner would like help with oo-modelling > Benj, > > thanks for your input! > > The option of rendering different outputs is supposed to be part of The > Concept, but although you're affirming my assumption that All Roads Lead > to Rome, my hopes for a specific hint to one of those roads are > disappointed now :-) > > Even as I'm trying to discover OO ways of modeling that may not be even > sensible, I'm currently stuck, and I most likely would be stuck on the > procedural path as well. Actually, I have been playing and now I've > mostly run out of game ideas.. > > I would just like someone to push me into the right direction, > specifically addressing the matter of storing the line data (whether as > attribute or independent). > > I've been thinking about using a relational approch using two [storage > units], one containing type and positional data of a line, while the > other just stores line-type related information as color, width, .. > > As arrays apparently only support integer keys, and the order in which > the line elements are stored does not really matter, my guess is that a > hash using the position of each line (float) as keys, and the style of > line as value, plus another hash or array that contains just the > different styles might be a good approach. Why do you need to store the lines and ticks and bits of ruler at all? I don't think you need to. What you need to store is what makes one ruler unique (how long it is, what units it uses, how many gradations it has, what its colour is, where the bold gradations are...). That's the kind of thing that you would put in to a ruler, probably. But for starters (I'm not quite sure where your experience level is), I don't think you even know that you need that. I would try to just generate the SVG for a fixed ruler. In fact, I'd start by trying to generate the SVG for some parallel lines. 10 of them. Of unit length. I'd use ERB, and I'd look up an ERB tutorial. You'll find info about ERB here: http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html Or, you could just do it in ruby (I don't have a Ruby to hand to try this with, so it will have errors I expect): lines = 1..10 lines.each do |line_x| puts "draw_line_from #{line_x}, 0 to #{line_x}, 1" end You'll need lots more puts in there to get it to create actual SVG, and I doubt SVG has a command "draw_line_from x,y to x,y", so you'll need to fix that up too. Maybe the above is enough to get you started though. Best of luck, Ben