Class RMail::Serialize

In: | lib/rmail/serialize.rb
Parent: | Object

The RMail::Serialize class writes an RMail::Message object into an IO object or string. The result is a standard mail message in text form.

To do this, you pass the RMail::Message object to the RMail::Serialize object. RMail::Serialize can write into any object supporting the << method.

As a convenience, RMail::Serialize.write is a class method you can use directly:

     # Write to a file
     File.open('my-message', 'w') { |f|
       RMail::Serialize.write(f, message)
     }

# Write to a new string string = RMail::Serialize.write(’’, message)

Methods

new serialize write

Public Class methods

new(output, escape_from = nil)

Initialize this Serialize object with an output stream. If escape_from is not nil, lines with a leading From are escaped.

write(output, message)

Serialize a message into a given output object. The output object must support the << method in the same way that an IO or String object does.

Public Instance methods

serialize(message)

Serialize a given message into this object’s output object.