Class: IMAPToRSS::Handler::UPS
- Inherits:
-
IMAPToRSS::Handler
- Object
- IMAPToRSS::Handler
- IMAPToRSS::Handler::UPS
- Defined in:
- lib/imap_to_rss/handler/ups.rb
Overview
Turns messages from UPS into links to the tracking page
Instance Attribute Summary
Attributes inherited from IMAPToRSS::Handler
Instance Method Summary collapse
-
#handle(uids) ⇒ Object
Scans
uids
for UPS tracking numbers and turns them into RSS items. -
#initialize ⇒ UPS
constructor
Selects messages with ups in the From header.
Methods inherited from IMAPToRSS::Handler
#add_item, #each_message, handlers, inherited, #log, #setup
Constructor Details
#initialize ⇒ UPS
Selects messages with ups in the From header
11 12 13 |
# File 'lib/imap_to_rss/handler/ups.rb', line 11 def initialize @search = 'FROM', 'ups' end |
Instance Method Details
#handle(uids) ⇒ Object
Scans uids
for UPS tracking numbers and turns them into RSS items
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/imap_to_rss/handler/ups.rb', line 18 def handle(uids) uids, 'text/plain' do |uid, mail| mail.body =~ /Tracking Number:\s+(\w+)/ tracking_number = $1 next false unless $1 url = "http://wwwapps.ups.com/WebTracking/processRequest?tracknum=#{tracking_number}" description = %{Package shipped: <a href="#{url}">#{tracking_number}</a>} add_item mail.subject, description, mail.from, mail.date, url, mail., 'UPS' end end |