Here’s some code i’ve written to work with the COM interface to Internet
Explorer. It uses WIN32OLE.
def form # block
forms = $iec.document.forms
forms.extend( Enumerable )
form = forms.find{ |f| yield f }
form ? IEDomFormWrapper.new( form ) : nil
end
I originally expected this code to work without the call to forms.extend.
Since forms is a COM collection object, it supports “each”, and i figured
Enumerable should be mixed in automatically. I think it was Chad Fowler who
explained how i could do this myself – or maybe it was Nathaniel Talbot.
This still seems like a workaround, however. I would be interested to other
opinions on this matter.
In Visual Basic, for example, you can use any of the built in interation
operators on COM Collections. The difference is that Ruby has a lot more
"iteration operators".
Bret
···
Bret Pettichord, Software Tester
Consultant - www.pettichord.com
Author - www.testinglessons.com
Blogger - www.io.com/~wazmo/blog
Homebrew Automation Seminar
Scripting for Testers Tutorial
Portland, Seattle, Orlando, Austin
www.pettichord.com/training.html