Class: Mail::Retriever
- Inherits:
-
Object
- Object
- Mail::Retriever
- Defined in:
- lib/mail/network/retriever_methods/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#all(options = {}, &block) ⇒ Object
Get all emails.
-
#find_and_delete(options = {}, &block) ⇒ Object
Find emails in the mailbox, and then deletes them.
-
#first(options = {}, &block) ⇒ Object
Get the oldest received email(s).
-
#last(options = {}, &block) ⇒ Object
Get the most recent received email(s).
Instance Method Details
#all(options = {}, &block) ⇒ Object
Get all emails.
Possible options:
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
38 39 40 41 42 |
# File 'lib/mail/network/retriever_methods/base.rb', line 38 def all( = {}, &block) ||= {} [:count] = :all find(, &block) end |
#find_and_delete(options = {}, &block) ⇒ Object
Find emails in the mailbox, and then deletes them. Without any options, the five last received emails are returned.
Possible options:
what: last or first emails. The default is :first.
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
count: number of emails to retrieve. The default value is 10. A value of 1 returns an
instance of Message, not an array of Message instances.
delete_after_find: flag for whether to delete each retreived email after find. Default
is true. Call #find if you would like this to default to false.
55 56 57 58 59 |
# File 'lib/mail/network/retriever_methods/base.rb', line 55 def find_and_delete( = {}, &block) ||= {} [:delete_after_find] ||= true find(, &block) end |
#first(options = {}, &block) ⇒ Object
Get the oldest received email(s)
Possible options:
count: number of emails to retrieve. The default value is 1.
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
13 14 15 16 17 18 |
# File 'lib/mail/network/retriever_methods/base.rb', line 13 def first( = {}, &block) ||= {} [:what] = :first [:count] ||= 1 find(, &block) end |
#last(options = {}, &block) ⇒ Object
Get the most recent received email(s)
Possible options:
count: number of emails to retrieve. The default value is 1.
order: order of emails returned. Possible values are :asc or :desc. Default value is :asc.
26 27 28 29 30 31 |
# File 'lib/mail/network/retriever_methods/base.rb', line 26 def last( = {}, &block) ||= {} [:what] = :last [:count] ||= 1 find(, &block) end |