Class: Netposti::Message
- Inherits:
-
Object
- Object
- Netposti::Message
- Defined in:
- lib/netposti/message.rb
Instance Method Summary collapse
- #attachment_url ⇒ Object
- #date ⇒ Object
- #download_attachment(filename = nil) ⇒ Object
-
#initialize(message) ⇒ Message
constructor
A new instance of Message.
- #sender ⇒ Object
- #subject ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message) ⇒ Message
Returns a new instance of Message.
4 5 6 |
# File 'lib/netposti/message.rb', line 4 def initialize() @message = end |
Instance Method Details
#attachment_url ⇒ Object
20 21 22 23 24 |
# File 'lib/netposti/message.rb', line 20 def 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 ⇒ Object
12 13 14 |
# File 'lib/netposti/message.rb', line 12 def date @message.search('#message-detail-header-content .date').text end |
#download_attachment(filename = nil) ⇒ Object
26 27 28 |
# File 'lib/netposti/message.rb', line 26 def (filename = nil) @message.mech.get().save(filename) end |
#sender ⇒ Object
8 9 10 |
# File 'lib/netposti/message.rb', line 8 def sender @message.search('#message-detail-header-content .sender').text end |
#subject ⇒ Object
16 17 18 |
# File 'lib/netposti/message.rb', line 16 def subject @message.form.field_with(:name => 'messageSubjectTextField').value end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/netposti/message.rb', line 30 def to_hash { sender: sender, date: date, subject: subject, attachment_url: } end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/netposti/message.rb', line 39 def to_s "#{date}: #{sender} - #{subject}" end |