Just to be clear I meant to say why not just factor out JUST what's different.

On Mon, Feb 1, 2010 at 8:59 AM, Rick DeNatale <rick.denatale / gmail.com> wrote:
> On Mon, Feb 1, 2010 at 1:54 AM, R. Kumar <sentinel.2001 / gmx.com> wrote:
>> 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.  §
>>> assuming that you don't own Parent, and so have to work your magic in
>>> Child.     
>>> 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:
>>
>>       >>      >>   >>
>>       
>> att=Ncurses::A_NORMAL
>>      
>>  
>>
>> 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.
>
> So why not just factor out what's different between Parent and Child
>
> class Parent
>      
>  
>  do whatever you need
>  
>
>    
> [row, col]
>  
> end
>
> class Child < Parent
> def transform(row, col)
> [row - @top, col - @left]
> end
> end
>
> --
> Rick DeNatale
>
> Blog: http://talklikeaduck.denhaven2.com/
> Twitter: http://twitter.com/RickDeNatale
> WWR: http://www.workingwithrails.com/person/9021-rick-denatale
> LinkedIn: http://www.linkedin.com/in/rickdenatale
>
>



-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale