Sha256: 4c3c0d6a99d33f399173dbaa157ed7b45da59355da4c0cb582b18380b0f0f5e5

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

# encoding: utf-8

module Imap
  module Backup
    module Account
      class Folder
        REQUESTED_ATTRIBUTES = ['RFC822', 'FLAGS', 'INTERNALDATE']

        def initialize(connection, folder)
          @connection, @folder = connection, folder
        end

        def uids
          @connection.imap.examine(@folder)
          @connection.imap.uid_search(['ALL']).sort
        rescue Net::IMAP::NoResponseError => e
          warn "Folder '#{@folder}' does not exist"
          []
        end

        def fetch(uid)
          @connection.imap.examine(@folder)
          message = @connection.imap.uid_fetch([uid.to_i], REQUESTED_ATTRIBUTES)[0][1]
          message['RFC822'].force_encoding('utf-8') if RUBY_VERSION > '1.9'
          message
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
imap-backup-1.0.2 lib/imap/backup/account/folder.rb