Parent

RMail::Serialize

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)

Public Class Methods

new(output, escape_from = nil) click to toggle source

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

# File lib/rmail/serialize.rb, line 55
def initialize(output, escape_from = nil)
  @output = output
  @escape_from = escape_from
end
write(output, message) click to toggle source

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.

# File lib/rmail/serialize.rb, line 69
def Serialize.write(output, message)
  Serialize.new(output).serialize(message)
end

Public Instance Methods

serialize(message) click to toggle source

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

# File lib/rmail/serialize.rb, line 61
def serialize(message)
  calculate_boundaries(message) if message.multipart?
  serialize_low(message)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.