Chuck Brotman wrote:
> A more specific question: Does anyone have any clever ideas (or design
> patterns, etc.) for keeping a simulation-time clock and dispatching the
> appropriate metods/objects on each tick?
I am not sure that I have a "clever" idea, but I can point to similar
threads in the past. See ruby-talk #43139 and #41919:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/43139http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/41919
I can also share with you a little insight I got while playing with GUI
frameworks in Ruby. Most (I dare say all) GUI frameworks will have a
Timer class which is easy to use and will accomplish what you want.
I have used the one in wxRuby (http://rubyforge.org/projects/wxruby/)
and it works perfectly. Like so:
#... instantiate
@timer = Wx::Timer.new(self, :timer.id)
evt_timer(:timer.id) {on_timer}
#...
def on_timer
#
# take action
#
end
#... use
@timer.start(@delay)
@timer.stop
#...
Does this sound like what you want? I will gladly share the real code
(which is more complex) if you are interested.
Thanks,
-- Shashank