Ruby signals

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:

thanks in advance.

On Mon, Apr 21, 2008 at 12:49 PM, Martin V. [email protected]
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/.

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/


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

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

Kind regards

robert

Kind regards

robert

thanks robert.

It´s perfect for me this solution

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs