Lex Williams wrote: > Nit Khair wrote: >> Nit Khair wrote: >>> I am trying to extend a class developed by someone else (its from the >>> ncurses-ruby lib). I need to add some fields and methods to it. >>> >> >> On further thought I am wondering if being inside a module makes that >> class different. Like some sort of static or factory class. Nothing >> coming up on google on "module classes" or classes within modules. >> >> Could someone explain this or point me to a link. I read that modules >> cannot be instantiated or subclasses - fine. What of classes declared in >> them ? > > why don't you take advantage of open classes ? > > you can write this : > > class MyClass > attr_accessor :myfield > end > > and then you can access myfield using any instance of that class . The > same goes with methods . > > If you write : > > class MyClass > def my_new_method > #some logic here > end > end > > then , all your objects will have that method . Are you by any chance saying the same thing i have done above, when i copied the Module Class thing from the original source and added my method and data to it ? However, this much is working, but i need a heirarchy. I am unable to extend this and add methods to it. If the original class was declared as: >Module MyClass > class MYCLASS > attr_accessor :myfield > end >end I can copy this, and add: attr_accessor :newfield This is okay. But when i do: class AnotherClass < MYCLASS attr_accessor :anotherfield end then i get a NoMethodError pointing to MyClass::MYCLASS. I get no error when instantiating AnotherClass, only when i access the method added. I need a heirarchy of classes under Ncurses::FORM. -- Posted via http://www.ruby-forum.com/.