Class: WatirmarkEmail::EmailCollection
- Inherits:
-
Object
- Object
- WatirmarkEmail::EmailCollection
- Includes:
- Enumerable
- Defined in:
- lib/watirmark_email/email_collection.rb
Instance Method Summary collapse
- #[](x) ⇒ Object
- #add_emails(email_info) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ EmailCollection
constructor
A new instance of EmailCollection.
- #length ⇒ Object (also: #size)
Constructor Details
#initialize ⇒ EmailCollection
27 28 29 |
# File 'lib/watirmark_email/email_collection.rb', line 27 def initialize @emails = [] end |
Instance Method Details
#[](x) ⇒ Object
39 40 41 |
# File 'lib/watirmark_email/email_collection.rb', line 39 def [](x) @emails[x] end |
#add_emails(email_info) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/watirmark_email/email_collection.rb', line 48 def add_emails(email_info) #should be an array of Net::IMAP::FetchData or a single class email_info = [email_info] unless email_info.is_a?(Array) email_info.each do |email| envelope = email.attr["ENVELOPE"] body_text = email.attr["BODY[TEXT]"] body_raw = email.attr["BODY[]"] uid = email.attr["UID"] @emails << Email.new(envelope, body_text, body_raw, uid) end end |
#each(&block) ⇒ Object
31 32 33 |
# File 'lib/watirmark_email/email_collection.rb', line 31 def each(&block) @emails.each(&block) end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/watirmark_email/email_collection.rb', line 35 def empty? @emails.empty? end |
#length ⇒ Object Also known as: size
43 44 45 |
# File 'lib/watirmark_email/email_collection.rb', line 43 def length @emails.length end |