On Wed, 10 Nov 2004, Joe Laughlin wrote:

> I have a class that represents an airplane.  This class has a bunch of data
> members: x/y/z positions, x/y/z velocities, pitches, rolls, etc.  What I did
> is let the user configure what different attributes the airplane had in a
> YAML config file, then have the airplane class read in that file and setup
> attr_accessors for each attribute in the file.
>
> I have another object (call it airplane_drawing) that is responsible for
> drawing this airplane on the screen.  It needs to have access to some of the
> attributes of the airplane, and it needs have some of its own attributes
> changed whenever airplane's attributes changes.
>
> What is the best way to get airplane_drawing to be notified whenever some
> attribute of airplane is changed?  Should I have a thread (or similar) that
> checks the airplane object to see if anything's changed?
>
> I hope I've explained this well enough for people to understand... I feel
> like this is a fairly common thing to do, but I'm not sure of the best way
> to do it.
>
> Thanks,
> Joe

check out

   observer.rb in ruby's lib dir.

it has an example in it.

-a
--
===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself.  --Shunryu Suzuki
===============================================================================