From: Gavin Sinclair Date: 2002-11-08T08:36:31+09:00 Subject: Re: understanding modules/classes From: "Eric Schwartz" > Austin Ziegler writes: > > On Thu, 7 Nov 2002 10:27:02 +0900, Eric Schwartz wrote: > > > Okay, that's not a problem. But I can't figure out how to export > > > classes from my module into the global namespace. In Perl, I'd > > > just add the functions to @EXPORT, and be done with it. Can this > > > be done in Ruby as well, or am I just thinking about it the wrong > > > way? Should I be creating my CGI executable in that same module as > > > well? Or am I just over-organizing here? > > > > Easily enough to do: > > > > Okay, thanks to you and Gavin. One last question: is it good style to > put that in the class files? That is, do I put the 'include Foo' in > bar.rb, or in the file that 'require's it? I understand it doesn't > matter; I'm trying to get an idea for good Ruby style. > > -=Eric It is perfectly good style to include a module in a class. That is one of the primary aims of modules: in this sense, they are called mix-ins. BTW, since you expressed thanks, can I ask a favour in return? Can you write a post, with "[FAQ]" in the title, summarising the problem and solution? Then someone can easily find this information later and add it to the Ruby FAQ. Thanks! Gavin