class Netposti::Message
Public Class Methods
new(message)
click to toggle source
# File lib/netposti/message.rb, line 4 def initialize(message) @message = message end
Public Instance Methods
attachment_url()
click to toggle source
# File lib/netposti/message.rb, line 20 def attachment_url pdf_icon_value = @message.search('.small-pdf-icon').first.attributes['onclick'].value download_path = pdf_icon_value.match(/window.location.href='.(.*?)'/)[1].split('-', 2).last @message.uri.to_s + '-' + download_path end
date()
click to toggle source
# File lib/netposti/message.rb, line 12 def date @message.search('#message-detail-header-content .date').text end
download_attachment(filename = nil)
click to toggle source
# File lib/netposti/message.rb, line 26 def download_attachment(filename = nil) @message.mech.get(attachment_url).save(filename) end
sender()
click to toggle source
# File lib/netposti/message.rb, line 8 def sender @message.search('#message-detail-header-content .sender').text end
subject()
click to toggle source
# File lib/netposti/message.rb, line 16 def subject @message.form.field_with(:name => 'messageSubjectTextField').value end
to_hash()
click to toggle source
# File lib/netposti/message.rb, line 30 def to_hash { sender: sender, date: date, subject: subject, attachment_url: attachment_url } end
to_s()
click to toggle source
# File lib/netposti/message.rb, line 39 def to_s "#{date}: #{sender} - #{subject}" end