From: 7stud -- Date: 2009-05-04T02:44:28+09:00 Subject: Re: modules and classes question Marcelo Barbudas wrote: > Hi, > > This is a serious noob question. > > I am trying to write a small library and have the following situation: > > class Main > //initializes connection > > def request(blabla) > end > end > > class Resource < Main > //different API calls > def call > //bla bla > request(call) > end > end > > I would like to let the user do something like the AWS library: > Library::Main.initialize_connection(data) // initializes everything > and then just: > Library::Resource.method // and this should work > > In Main I have the function that fills the data, I just don't know how > to implement the Resource class. I'm not sure what your issue is, so let's start with this: module Library class Main def Main.initialize_stuff puts "initializing" end end class Resource def Resource.meth puts "executing meth" end end end Library::Main.initialize_stuff Library::Resource.meth --output:-- initializing executing meth Now what do you want to do? -- Posted via http://www.ruby-forum.com/.