From: Matt Brooks Date: 2009-11-14T08:02:37+09:00 Subject: Re: Module with a class? > If I understood correctly, he wants objects of class Hello to call > methods on the instance of Core which created them. Something like > (untested): > > class Hello > def initialize core > @core = core > end > def say > puts "hello: #{@core.msg}" > end > end > > class Core > def initialize msg > @msg = msg > @hello=nil > end > attr_reader :hello, :msg > > def add_hello_widget > @hello= Hello.new self # pass the instance of core to the hello > instance > end > end > > core = Core.new "i'm core" > core.add_hello_widget > core.hello.say #=> "hello: i'm core" > > Hope this helps, > > Jesus. Judson's response would have been correct if the say method in hello would have called a core method from the instance of core object that create the hello object... I think Jesus' response is what I needed, I have not tested it yet... but I am excited to try this on Monday!!! However, Now how would this work if both classes are in different files??? I think this is what I need if they were in same file, so can I just require the Hello file at the top of core, no module stuff needed if want them in separate files?!?! Thanks again Jesus Matt -- Posted via http://www.ruby-forum.com/.