Class: WatirmarkEmail::EmailCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/watirmark_email/email_collection.rb

Instance Method Summary collapse

Constructor Details

#initializeEmailCollection



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

#lengthObject Also known as: size



43
44
45
# File 'lib/watirmark_email/email_collection.rb', line 43

def length
  @emails.length
end