From: Michael Garriss Date: 2003-08-01T07:09:07+09:00 Subject: Re: Extracting a parent class Sorry...I should have been more clear. While this works it does not mantain the state. I would like all the members of 'b' that are class A members to be set in 'a'. Daniel Carrera wrote: >Answer: >a = b.class.superclass.new > >Why: >b.class == B >b.class.superclass == A >b.class.superclass.new == A.new > >Cheers, >Daniel. > >On Fri, Aug 01, 2003 at 06:53:01AM +0900, Michael Garriss wrote: > > >>Sorry about the newbie question but.... >> >>class A >> attr_accessor :a >>end >> >>class B < A >> attr_accessor :b >>end >> >>b = B.new >>b.a = "some data" >>b.b = "some more data" >>a = b.????? >> >>How do I set 'a' from 'b' so that a is of class A and not class B? I >>don't want the extra info, I want just the subset of members found in >>the parent class. Is there a way to cast? >> >>TIA >>Michael Garriss >> >> >> > > >