Should Win32Ole automatically support enumerable collections?

  • Thread starter Bret Pettichord
  • Start date
B

Bret Pettichord

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top