# Ruby signals

**URL:** <https://www.ruby-forum.com/t/ruby-signals/135345>\
**Category:** Ruby\
**Created:** [April 21, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-signals/135345 "2008-04-21T12:49:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 12:49pm UTC](https://www.ruby-forum.com/t/ruby-signals/135345/1 "2008-04-21T12:49:36Z")

</div>

Someone know like connect a signal inside a class??  
I am working in ruby gnome, but i thinkl this is a ruby generic  
question.

class One  
def initialize(callback)  
callback  
end

end

class Main  
def initialize  
One.new(“talk\_with\_me”)  
end

def talk\_with\_me  
puts “i am here”  
end

end

Here we can see a php5 doing the same:

> **[Splash screens with PHP-GTK](http://phpexperts.blogspot.com/2007/05/splash-screens-with-php-gtk.html)**
>
> Splash screen is a term used to describe an image that appears while a computer program is loading. Splash screens often don't cover the ent...

thanks in advance.

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 21, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/ruby-signals/135345/2 "2008-04-21T13:10:10Z")

</div>

On Mon, Apr 21, 2008 at 12:49 PM, Martin V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Someone know like connect a signal inside a class??  
> I am working in ruby gnome, but i thinkl this is a ruby generic  
> question.

I have no idea what Gnome really needs but the doc is pretty good IIRC.

> ## end
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

You could do different things, e.g. call a proc or instance\_eval a  
block, as I suspect that you need information of the class I would  
rather instance\_eval.

class Two  
def initialize &blk  
instance\_eval &blk  
end  
def say\_hello; puts “hello” end  
end

Two.new do say\_hello end

## HTH Robert

[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

Whereof one cannot speak, thereof one must be silent.  
Ludwig Wittgenstein

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 22, 2008, 8:41am UTC](https://www.ruby-forum.com/t/ruby-signals/135345/3 "2008-04-22T08:41:06Z")

</div>

On 21.04.2008 13:09, Robert D. wrote:

> > 
> 
> You could do different things, e.g. call a proc or instance\_eval a  
> Two.new do say\_hello end  
> Here’s my - equally Gnome agnostic - suggestion

class Model  
def initialize(&callback)  
@cb = callback  
end

def some\_event  
@cb.call  
end  
end

class View  
def initialize  
@md = Model.new { talk\_with\_me }  
end

def talk\_with\_me  
puts “i am here”  
end

end

But also see [http://ruby-doc.org/core/classes/Observable.html](http://ruby-doc.org/core/classes/Observable.html)

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![martin\_gnu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/edb3f5/32.png) [@martin\_gnu](https://www.ruby-forum.com/u/martin_gnu)\
**Post date:** [April 22, 2008, 9:04am UTC](https://www.ruby-forum.com/t/ruby-signals/135345/4 "2008-04-22T09:04:02Z")

</div>

> Kind regards
> 
> robert

thanks robert.

ItÂ´s perfect for me this solution
