I’m apparently missing something fundamental in my knowledge of classes
and how they interoperate.
Let’s say I have lots of classes, such as the following:
class Foo
def method
puts “hi”
end
end
class Bar
def method
puts “hi”
end
end
And I want to write another class that uses all of those classes. For
example:
class Baz
foo.method
bar.method
end
What I’m doing right now is initiating all the classes as follows:
$foo = Foo.new
$bar = Bar.new
So I then have:
class Baz
$foo.method
$bar.method
end
But this has to be wrong (?)
I could make them all modules and then include them as needed, but I’d
still end up with:
class baz
include Foo
include Bar
…x20ish
Essentially, I have about 20 classes and many of them talk to each
other, so they have to be aware of each other. What’s the right way to
structure all of this?
Many thanks in advance!
Andrew