Class: Imap::Backup::Serializer::Message
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::Message
- Extended by:
- Forwardable
- Defined in:
- lib/imap/backup/serializer/message.rb
Instance Attribute Summary collapse
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(uid:, offset:, length:, mbox:, flags: []) ⇒ Message
constructor
A new instance of Message.
- #message ⇒ Object
- #to_h ⇒ Object
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
#flags ⇒ Object
Returns the value of attribute flags.
9 10 11 |
# File 'lib/imap/backup/serializer/message.rb', line 9 def flags @flags end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
10 11 12 |
# File 'lib/imap/backup/serializer/message.rb', line 10 def length @length end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
11 12 13 |
# File 'lib/imap/backup/serializer/message.rb', line 11 def offset @offset end |
#uid ⇒ Object
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
#message ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/imap/backup/serializer/message.rb', line 36 def @message = begin raw = mbox.read(offset, length) Email::Mboxrd::Message.from_serialized(raw) end end |
#to_h ⇒ Object
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 |