Class: Email::Mboxrd::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/email/mboxrd/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(supplied_body) ⇒ Message

Returns a new instance of Message.



19
20
21
22
# File 'lib/email/mboxrd/message.rb', line 19

def initialize(supplied_body)
  @supplied_body = supplied_body.clone
  @supplied_body.force_encoding("binary")
end

Instance Attribute Details

#supplied_body ⇒ Object (readonly)

Returns the value of attribute supplied_body.



7
8
9
# File 'lib/email/mboxrd/message.rb', line 7

def supplied_body
  @supplied_body
end

Class Method Details

.from_serialized(serialized) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/email/mboxrd/message.rb', line 9

def self.from_serialized(serialized)
  cleaned = serialized.gsub(/^>(>*From)/, "\\1")
  # Serialized messages in this format *should* start with a line
  #   From xxx yy zz
  if cleaned.start_with?("From ")
    cleaned = cleaned.sub(/^From .*[\r\n]*/, "")
  end
  new(cleaned)
end

Instance Method Details

#to_serialized ⇒ Object



24
25
26
# File 'lib/email/mboxrd/message.rb', line 24

def to_serialized
  "From " + from + "\n" + mboxrd_body + "\n"
end