Is it possible to get instances of stacks and flows and other stuff
outside of calling "stack" or "flow" and having them added right
away? I was thinking about making tables, and thought it would be
nice to have some sort of array subscripty accessor for the cells of
a table (which would really be stacks). I imagined it looking
something like this:
@container = stack
@table = Table.new(3,3)
@container.append { @table }
@table[0,1].append { para "Hello!" }
For my first attempt, I decided to go with a simpler one-dimensional
table.
class OneDimensionalTable
def initialize(size)
@cells = Shoes::Stack.new
size.times { |i| @cells.append { Shoes::Flow.new } }
end
def [](index)
@cells.contents[index]
end
end
This really isn't such a good place to start, since it crashes even
if I just ask for a new instance of the class. Am I fighting against
Shoes by wanting to create things without first inserting them? Is
using Shoes::Stack to make things just not reasonable? Perhaps I am
expecting that Shoes be more like the browser DOM than it really is?
-- Michael Daines