I have a file that has a class called “Core” that defines tons of
generic methods which populate tons of @instance variables and has
methods to talk to another machine over tcp, etc…
I have other files, such as hello.rb which has a “Hello” class and
world.rb which has a “World” class. I require these files at the top of
the Core classes file.
The point is I have a 4th ruby script file that requires the “Core”
file, and then makes an object of that Core class, called core. Now the
user will invoke Core methods as normal from this outside file, such as
core.connect_to_widget or core.disconnect_from_widget
It also creates general variables, populates them, opens up a tcp socket
talks to another machine, gets info populates instance variables…etc.
Now the user has decided, in the 4th Ruby script file, that he now needs
a Hello object, so calls core.add_hello_widget inwhich the core method
creates the hello object, @hello = Hello.new.
This hello object has methods which it specifically uses from the hello
class, however it needs to call some methods from the Core file and have
access to its attr_accessor instance variables.
Since the core object originally created this hello object, I want the
4th Ruby script file to be able to call a method such as
core.hello.<method_name_inside_hello_class> where this method might call
a method from within the core class.
I keep getting errors about accessing these variables and methods in the
I have tried making a module for the hello file, and tried including a
class called hello inside the module hello. And then in the core class
i included this module.
***When a core method creates the hello class as some later point I WANT
it to know hey here is this module which has defined this class hello, I
will make a hello object, and since core is creating this hello object,
go ahead and have access to the variables and methods inside core.
Is this possible??? Seems like module can’t have a class?
I may need to reexplain it, but basically want classes in different
files, but want the other classes to have access to 1 core files’
objects instance variables and methods, since this core object will be
creating the other objects of the other classes in the other files…