From: "David A. Black" Date: 2008-10-03T04:07:30+09:00 Subject: Re: Problem extending (adding methods) to class Hi -- On Fri, 3 Oct 2008, Nit Khair wrote: > David A. Black wrote: >> Hi -- >> >> On Fri, 3 Oct 2008, Nit Khair wrote: >> >>>> Similarly if you want to subclass ClassC, you can do it inside ModuleM >>>> or outside: >>> class AForm < Ncurses::FORM >> I don't think it was exactly this, because there is no Ncurses::FORM. >> Try the code in my previous post and see if it works for you. If not, >> please post some actual code that triggers the error you're talking >> about. I can't duplicate it. >> >> >> David > > Maybe we are onto something. Your code works fine. But doesn't FORM.new > require a fields object ? I tried many variations so i cant remember > what it was but here is the last one I have before i rewrote. > > > include Ncurses > include Ncurses::Form > > class RBForm < FORM > attr_accessor :ffields > def initialize(fields) > super(fields) > @ffields = fields > end > def set_ffields(fields) > @ffields = fields > end > def get_ffields > @ffields > end > end > > > get_ffields throws a NoMethodError. > If i access ffields, that too gives an error. > > It is instantiated thus: > f=RBQueryForm.new(fields); > > RBQueryForm is subclassed from RBForm. > > See if you can spot the error here itself. Otherwise I will try to cut > and make a tiny version that you can run and see. *Please* post some real code that contains the error. Otherwise it just goes back and forth. This code runs. I've changed super(fields) to super() because with an argument I got an error (it expected zero arguments). I don't know exactly what the fields are supposed to consist of so I've used a placeholder ("abc"). require 'rubygems' require 'ncurses' include Ncurses include Ncurses::Form class RBForm < FORM attr_accessor :ffields def initialize(fields) super() @ffields = fields end def set_ffields(fields) @ffields = fields end def get_ffields @ffields end end RBForm.new("abc").set_ffields("abc") David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!