From: "R. Kumar" Date: 2010-02-01T15:54:46+09:00 Subject: Re: Inheritance related problem Sean DeNigris wrote: >> When Parent's printa is called, it calls its own printb. >> However, when Child's printa is called, it calls Parent's printa, which >> (in this case) i was hoping would call Parent's printb directly. But it >> (correctly) calls Child's printa which once again reduces the arg. >> >> So my arg gets reduced twice. I suppose i could use some flags to >> prevent this, But is there any direct way i can coerce Parent printa to >> call only Parent printb. > > I'm having trouble understanding how you got into this position. I'm > assuming that you don't own Parent, and so have to work your magic in > Child. For the specific example you described, the following will > work... > I own both. Parent is a wrapper around ncurses Window. Child is a wrapper around ncurses Pad. However, they are used in a similar manner. So in the original app, i used only Window. Now in many cases I use Pad. They both should work interchangeably since they essentially do the same thing but often in different ways. An object could use Window, or Pad. However, stuff like printing a border or writing a string onto the window are essentially the same except that the offsets in Window are absolute whereas the Pad offsets are relative. So when Pad calls super it only has to make the relative offsets absolute: def printstring(row, col, value, color, attrib=Ncurses::A_NORMAL) super(row - @top, col - @left, value, color, attrib) end # printstring def print_border row, col, height, width, color, att=Ncurses::A_NORMAL super(row - @top, col - @left, height, width, color, att) end Now in the parent Window, print_border does a call to printstring to reset the background. Unfortunately, the child's printstring gets called and @top and @left get decremented again. I looked at your workaround -- a bit complicated, and could slow things down since display has to be fast. I can use a variable that I set and check, however, is there some direct way in ruby. I know the answer is most likely NO, but just thought i'd ask in case i've overlooked something. -- Posted via http://www.ruby-forum.com/.