[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Neewby question: how to monitor a variable value

Luc Juggery

10/20/2006 10:41:00 AM

Hello All,

I remember reading in a book that we could very easily monitor the
value of a variable and have for instance an alert message displayed
each time this variable s modified. I do not manage to find how to do
this anymore.
Would you have any clues ?

Thanks a lot,
Luc

6 Answers

Farrel Lifson

10/20/2006 11:05:00 AM

0

On 20/10/06, Luc Juggery <luc.juggery@gmail.com> wrote:
> Hello All,
>
> I remember reading in a book that we could very easily monitor the
> value of a variable and have for instance an alert message displayed
> each time this variable s modified. I do not manage to find how to do
> this anymore.
> Would you have any clues ?
>
> Thanks a lot,
> Luc

Sounds like you need the observer design pattern:
http://wiki.rubygarden.org/Ruby/page/show/Obser...

Farrel

Luc Juggery

10/20/2006 11:15:00 AM

0

Thanks a lot Farrel,
This is exactly what I needed !!!!
Luc

On 10/20/06, Farrel Lifson <farrel.lifson@gmail.com> wrote:
> On 20/10/06, Luc Juggery <luc.juggery@gmail.com> wrote:
> > Hello All,
> >
> > I remember reading in a book that we could very easily monitor the
> > value of a variable and have for instance an alert message displayed
> > each time this variable s modified. I do not manage to find how to do
> > this anymore.
> > Would you have any clues ?
> >
> > Thanks a lot,
> > Luc
>
> Sounds like you need the observer design pattern:
> http://wiki.rubygarden.org/Ruby/page/show/Obser...
>
> Farrel
>
>

Gavin Kistner

10/20/2006 2:10:00 PM

0

Luc Juggery wrote:
> I remember reading in a book that we could very easily monitor the
> value of a variable and have for instance an alert message displayed
> each time this variable s modified. I do not manage to find how to do
> this anymore.

While I'm sure many other similar libraries exist, I'd like to offer up
my own EventTarget library. Instead of being tied to a single event
like the Observable pattern, you can register different callbacks for
different types of actions that occur.

http://phrogz.net/RubyLibs/rdoc/files/EventTarg...

One of these days I'll get around to learning how to gem up my libs.
Until then, you can download the source code from the link on that page.

Luc Juggery

10/20/2006 2:31:00 PM

0

Thanks a lot gavin,
I will also give it a try.

Luc

On 10/20/06, Phrogz <gavin@refinery.com> wrote:
> Luc Juggery wrote:
> > I remember reading in a book that we could very easily monitor the
> > value of a variable and have for instance an alert message displayed
> > each time this variable s modified. I do not manage to find how to do
> > this anymore.
>
> While I'm sure many other similar libraries exist, I'd like to offer up
> my own EventTarget library. Instead of being tied to a single event
> like the Observable pattern, you can register different callbacks for
> different types of actions that occur.
>
> http://phrogz.net/RubyLibs/rdoc/files/EventTarg...
>
> One of these days I'll get around to learning how to gem up my libs.
> Until then, you can download the source code from the link on that page.
>
>
>


--
@bientot,
Luc

Joel VanderWerf

10/20/2006 10:00:00 PM

0

Luc Juggery wrote:
> Hello All,
>
> I remember reading in a book that we could very easily monitor the
> value of a variable and have for instance an alert message displayed
> each time this variable s modified. I do not manage to find how to do
> this anymore.
> Would you have any clues ?

See also http://raa.ruby-lang.org/project/.... (And see the
example in my post a few minutes ago on the thread "[ANN] Dependency
1.0.0".)

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Charles Roper

10/20/2006 10:43:00 PM

0

> One of these days I'll get around to learning how to gem up my libs.
> Until then, you can download the source code from the link on that page.

I just got back from reading this on Ruby Inside and though I'd give
you a heads up:

http://www.rubyinside.com/generate-your-own-ruby-gems-more-easil...

Charles