Jan E. wrote in post #1083732:

> Apart from that, I think the main problem is that you didn't structure
> the code. This makes it hard to understand and very error-prone. Some
> parts also look strange and overly complicated (e. g. all the "for ...
> in" loops that are completely useless in ruby).
>
> So unless this is supposed to be just a quick hack, it might be a good
> idea to start from scratch and make a clean design. For example, how
> about defining classes for a canvas, a line and a shape (group of
> lines)? The canvas receives lines and shapes and generates the output
> file. And a shape is for grouping lines and transforming them (shift,
> rotate etc.).
>
> Something like that:
>
> canvas = Canvas.new
> line = Line.new [2, 3, 1], [5, 2, 1]
> canvas << line
> line.move x: 12
> output = canvas.generate_data
>
> You see? It's much clearer than a bunch of loops and array stuff,
> because you can actually *see* what happens. Custom shapes like a plane
> or a block could then simply be created by copying and transforming
> lines.

Thanks. I will clean up the code and try again.

Alan Forrester

-- 
Posted via http://www.ruby-forum.com/.