Class: MailStoreAgent
- Inherits:
-
Array
- Object
- Array
- MailStoreAgent
- Defined in:
- lib/mail-store-agent.rb
Instance Method Summary collapse
- #accounts ⇒ Object
- #get(address) ⇒ Object
-
#initialize ⇒ MailStoreAgent
constructor
A new instance of MailStoreAgent.
-
#peek(address) ⇒ Object
Peek at next message without removing it from queue.
Constructor Details
#initialize ⇒ MailStoreAgent
Returns a new instance of MailStoreAgent.
4 5 6 7 |
# File 'lib/mail-store-agent.rb', line 4 def initialize @queues = {} @next_unsorted = 0 # index of next unsorted e-mail end |
Instance Method Details
#accounts ⇒ Object
9 10 11 12 |
# File 'lib/mail-store-agent.rb', line 9 def accounts self.sort_mail! return @queues.keys end |
#get(address) ⇒ Object
14 15 16 17 18 |
# File 'lib/mail-store-agent.rb', line 14 def get(address) self.sort_mail! q = @queues[address] return q && q.length > 0 ? q.shift : nil end |
#peek(address) ⇒ Object
Peek at next message without removing it from queue
21 22 23 24 25 |
# File 'lib/mail-store-agent.rb', line 21 def peek(address) self.sort_mail! q = @queues[address] return q && q.length > 0 ? q[0] : nil end |