WIN32OLEのメソッドをirbで補完する

なんか動いたみたいだけどこんな簡単でいいのかな。

irb/ole.rb

require 'win32ole'
require 'irb/completion'

class WIN32OLE
  alias :orig_methods :methods
  def methods(flag = true)
    @ole_methods ||= ole_methods.map { |m| m.to_s.downcase }
    @ole_methods | orig_methods(flag)
  end
end

動作例:

D:\jitte\Ruby> irb -r irb/ole
irb(main):001:0> app = WIN32OLE.new('Excel.Application')
=> #<WIN32OLE:0x29b88e8>
irb(main):002:0> app.work[TAB][TAB]
app.workbooks          app.worksheetfunction  app.worksheets

追記:
(ole_methods rescue [])あたりにしとくと吉かも。