From: David Alan Black Date: 2001-12-22T12:07:48+09:00 Subject: [ruby-talk:29281] Re: Instance Subclassing Hi -- On Sat, 22 Dec 2001, Ralph Mason wrote: > I would like to do an instance subclass. > > e.g. > > class MyClass < Win32OLE.new("myserver.myclass") > > //More methods here > > end > > Is there any way to accomplish this? I know I can fake it using > method_missing, but the above seems far more rubyish. > This probably seems like a strange thing to do, but here is the > reason. I want to subclass com objects using RubyCOM so that I can > add methods to existing com objects. These objects are then exposed > as the originals. This means you can extend objects written in > other languages using ruby, a very desirable thing to do with legacy > code. I have no Win32OLE experience at all... but could you do: w = Win32OLE.new("myserver.myclass") class << w # new methods end or def w.method_name # stuff end ? David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav