From: Daniel Berger Date: 2002-05-12T00:44:48+09:00 Subject: Ruby extensions - pushing classes into other modules Hi all, I'm trying to write extensions for a bunch of little unix utilities, such as hostname, the uname information (sysname, nodename), who, etc. I want to create a base class called "Sys" that would simply serve as a common namespace for future modules. I don't want to have to do a series of 'rb_define_class_under' within the Sys.c file, since it will quickly become unwieldy as more and more functionality is added. In other words, if I've created a 'Sys' module name (in the Sys.c file), I would like to have a Uname.c, Hostname.c, Who.c, etc. The actual ruby script would then look something like this: require 'Sys' puts Sys::Hostname.hostname # class method u = Sys::Uname.new # traditional object puts u.nodename who = Sys::Who.new(7) who.each |user| do puts who.user end etc, etc. I would like to be able to stick each class in its own .c file. This would not only help reduce serious bloat in one file, it would allow others to easily add their own extensions under the 'Sys' namespace. I've played with 'rb_define_module_under', 'rb_include_module', 'rb_extend_object', etc, but I'm obviously just not *getting it*. Perhaps I don't need the Sys.c file at all? All help greatly appreciated. Regards, Dan