Class: Imap::Backup::Serializer::Message

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/imap/backup/serializer/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uid:, offset:, length:, mbox:, flags: []) ⇒ Message

Returns a new instance of Message.



19
20
21
22
23
24
25
# File 'lib/imap/backup/serializer/message.rb', line 19

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

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



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

def flags
  @flags
end

#lengthObject (readonly)

Returns the value of attribute length.



10
11
12
# File 'lib/imap/backup/serializer/message.rb', line 10

def length
  @length
end

#offsetObject (readonly)

Returns the value of attribute offset.



11
12
13
# File 'lib/imap/backup/serializer/message.rb', line 11

def offset
  @offset
end

#uidObject

Returns the value of attribute uid.



12
13
14
# File 'lib/imap/backup/serializer/message.rb', line 12

def uid
  @uid
end

Instance Method Details

#messageObject



36
37
38
39
40
41
42
# File 'lib/imap/backup/serializer/message.rb', line 36

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

#to_hObject



27
28
29
30
31
32
33
34
# File 'lib/imap/backup/serializer/message.rb', line 27

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