this has been answered before, lack proper vocabulary find solution using board search.
what want acheive calling methods of class’ instance of class.
i think crude example illustrates want acheive:
class classa def method_a return 'first example' end def method_b return 'second example' end end class classb def initialize object = classa.new end end the_example = classb.new the_example.[whatever-i’m-missing-to-talk-with-object].method_b # should return 'second exampe'
object
needs instance variable doesn't go out of scope after call initialize
, call @object
instead.
then you'll need make @object
accessible outside of classb
's definition, you'll want declare that.
class classb attr_reader :object # lets call 'some_instance_of_classb.object' def initialize @object = classa.new end end
Comments
Post a Comment