Class: Imap::Backup::Serializer::MessageEnumerator

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/serializer/message_enumerator.rb

Overview

Enumerates over a list of stores messages

Instance Method Summary collapse

Constructor Details

#initialize(imap:) ⇒ MessageEnumerator

Returns a new instance of MessageEnumerator.

Parameters:



9
10
11
# File 'lib/imap/backup/serializer/message_enumerator.rb', line 9

def initialize(imap:)
  @imap = imap
end

Instance Method Details

#run(uids:) {|message| ... } ⇒ void

This method returns an undefined value.

Enumerates over the messages

Parameters:

  • uids (Array<Integer>)

    the message UIDs of the messages to iterate over

Yield Parameters:



17
18
19
20
21
22
23
24
25
26
# File 'lib/imap/backup/serializer/message_enumerator.rb', line 17

def run(uids:, &block)
  uids.each do |uid_maybe_string|
    uid = uid_maybe_string.to_i
    message = imap.get(uid)

    next if !message

    block.call(message)
  end
end