Sha256: 88c67bdcbe5fe578f31c61b45bd160c93db3a7ce145f0b8f35549dfb534bb2f3

Contents?: true

Size: 992 Bytes

Versions: 16

Compression:

Stored size: 992 Bytes

Contents

require "email/mboxrd/message"

module Imap; end

module Imap::Backup
  class Serializer::Message
    attr_accessor :uid
    attr_accessor :flags
    attr_reader :offset
    attr_reader :length
    attr_reader :mbox

    # TODO: delegate to Mboxrd::Message

    def initialize(uid:, offset:, length:, mbox:, flags: [])
      @uid = uid
      @offset = offset
      @length = length
      @mbox = mbox
      @flags = flags.map(&:to_sym)
    end

    def to_h
      {
        uid: uid,
        offset: offset,
        length: length,
        flags: flags.map(&:to_s)
      }
    end

    def message
      @message =
        begin
          raw = mbox.read(offset, length)
          Email::Mboxrd::Message.from_serialized(raw)
        end
    end

    def body
      @body ||= message.supplied_body
    end

    def imap_body
      @imap_body ||= message.imap_body
    end

    def date
      @date ||= message.date
    end

    def subject
      @subject ||= message.subject
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
imap-backup-14.1.1 lib/imap/backup/serializer/message.rb
imap-backup-14.1.0 lib/imap/backup/serializer/message.rb
imap-backup-14.0.0 lib/imap/backup/serializer/message.rb
imap-backup-13.4.0 lib/imap/backup/serializer/message.rb
imap-backup-13.3.0 lib/imap/backup/serializer/message.rb
imap-backup-13.2.0 lib/imap/backup/serializer/message.rb
imap-backup-13.1.0 lib/imap/backup/serializer/message.rb
imap-backup-13.0.0 lib/imap/backup/serializer/message.rb
imap-backup-12.1.0 lib/imap/backup/serializer/message.rb
imap-backup-12.0.0 lib/imap/backup/serializer/message.rb
imap-backup-11.1.0 lib/imap/backup/serializer/message.rb
imap-backup-11.1.0.rc1 lib/imap/backup/serializer/message.rb
imap-backup-11.0.1 lib/imap/backup/serializer/message.rb
imap-backup-11.0.0 lib/imap/backup/serializer/message.rb
imap-backup-11.0.0.rc1 lib/imap/backup/serializer/message.rb
imap-backup-10.0.1 lib/imap/backup/serializer/message.rb