WindowsでRuby
#!/usr/home/bin/ruby/bin/ruby require 'win32ole' module OUTLOOK_CONST end class OutlookCalendar def OutlookCalendar::run cal = self.new begin yield cal ensure cal.quit end end def initialize(display = false) @outlook = WIN32OLE.new("Outlook.Application") WIN32OLE.const_load(@outlook, OUTLOOK_CONST) mapi = @outlook.GetNameSpace("MAPI") @calFolder = mapi.GetDefaultFolder(OUTLOOK_CONST::OlFolderCalendar) if display then @calFolder.Display end end def find(title) return @calFolder.items(title) end def each count = @calFolder.items.count for i in (1..count) do yield @calFolder.items(i) end end def quit @outlook.quit end end def snap(s) date, time = s.split " " yy, mm, dd = date.split "/" return [yy,mm,dd,time] end # main OutlookCalendar.run { |cal| cal.each do |item| s = snap(item.start) e = snap(item.end) dy = s[1] + "/" + s[2] + "/" + s[0] st = s[3] et = e[3] if (st == "00:00" && et == "00:00") then print "#{dy} - #{item.subject}\n" elsif (st == et) print "#{dy} #{st} | #{item.subject}\n" else print "#{dy} #{st}-#{et} | #{item.subject}\n" end end } =begin OutlookCalendarの使い方 #タイトルで探す cal = OutlookCalendar.new item = cal.find("業務ミーティング") p item.start p item.duration # 所要時間を分で表す整数 p item.end p item.subject #全部見て回る cal.each { |item| print item.subject } #片付ける cal.quit =end