From: Dave Burt Date: 2006-09-30T01:25:16+09:00 Subject: Re: Enumerable and WIN32OLE Masaki Suketa wrote: >> Enumerable#find method clashes the 'find' method of Excel Range object. >> This is the (only) reason why WIN32OLE does not include Enumerable. > > Enumerable#select method clashes the 'select' method of Excel Range object. > And I think this case is more painful than the 'find' case. You're right, we don't want to break people's range.find or range.select calls (at least in Ruby 1.8). What about something like this, though? For these methods, a block is always provided. For a COM method call, a block is never provided. Why not dispatch depending on block_given? class WIN32OLE include Enumerable %w( find select ).each do |m| alias_method "enum_#{m}", m define_method m do |*args| if block_given? send("enum_#{m}", *args) {|*a| yield *a } else invoke m, *args end end end end My preference for writing code for OLE is to use uppercase method calls (range.Select) and save lowercase for Ruby methods. But this should provide compatibility for people who have range.select in their code. IEnums should have Enumerable. Cheers, Dave