From: Glenn Parker Date: 2005-01-25T05:35:33+09:00 Subject: Re: Complex Library Object/Class and its Interface Trans wrote: > > It toke me some time to work this out in itself. And I thought I had > finally gotten a fairly nice interface here. But to my dismay, I just > discovered that I can't subclass Marker b/c I loose the definitions of > the above attributes (ie. exclusive, start, stop). What exactly do you mean when you say you "lose the definitions"? The definitions for Marker will remain accessible via the Marker scope, but a derived class will start out with its own set of (empty) definitions. Do you want auto-inherit for class instance variables? class Parent class << self def set_name(n) @name = n end def name (defined? @name) ? @name : superclass.name end end set_name "Smith" end class Child < Parent end class Grandchild < Child set_name "Jones" end puts "Parent.name = #{Parent.name}" puts "Child.name = #{Child.name}" puts "Grandchild.name = #{Grandchild.name}" Prints: Parent.name = Smith Child.name = Smith Grandchild.name = Jones -- Glenn Parker | glenn.parker-AT-comcast.net |