Win32ole type casting possible?

Hello all,

I have a problem when I try to automate an application using Rubys
win32ole
class. I’ll try to explain my problem by some simplified sample code:

oleObj = WIN32OLE.new( 'Some.COM.application' )
foo = oleObj.getFoo                #foo is either of type FooA or 

FooB
fooType = oleObj.getFooType

getFooType returns either ‘A’ or ‘B’. This determines the actual type of
foo. In case fooType is ‘A’, foo is of type FooA and has different
ole-methods than in case that fooType is ‘B’. If I use C# to automate
the
COM application, this can easily be solved by a typecast of form:

FooA foo = ( FooA )oleObj.getFoo(); //For the case that getFooType

returns ‘A’

As far as I know Rubys typing concept makes such a cast impossible. My
question therefore is: Does the win32ole class support a mechanism that
allows to convert the type of foo? If not, does anybody see other ways
of
solving this problem? I already considered writing a Ruby extension in C
and
do the typecast there, but I am not a windows expert, and all the
IDispatch
stuff really caused me severe headaches.

Thank you,
best regards
Daniel

2007/10/29, Daniel M. [email protected]:

… question about type casts of OLE objects …

Daniel, I don’t think you need type casts here. AFAIK you just call
the methods you want and win32ole should do the rest.

Regards,
Pit