From: Robert Dober Date: 2006-06-22T01:51:17+09:00 Subject: Re: Achieve pure object oriented design in Ruby ------=_Part_74196_15283971.1150908674347 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 6/21/06, gwtmp01@mac.com wrote: > > > On Jun 20, 2006, at 6:02 PM, Robert Dober wrote: > > The real problem is requirement 2) of the OP, instanciation of > > class B > > shall only be possible in class A, e.g. in an instance of A, I do > > not think > > this is possible, but I would not bet on it (not much). > > Why not just make B an anonymous class: > > class A > def initialize > @bclass =3D Class.new do > # class definition here > end > @bs =3D [] > end > > def another_b_please > @bs << @bclass.new > @bs.last > end > end Gary that is what I did, and discussed above. ( I used an anonymous class inside A, you use one inside an instance of A, which might be quite disturbing unless A is a singleton itself!!) One can create an accessor to @b at any time class A attr_accessor :bclass end A.new.bclass.new #voil=E0 cheers Robert > Gary Wright > > > > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_74196_15283971.1150908674347--