Class: RMail::Serialize
- Inherits:
-
Object
- Object
- RMail::Serialize
- Defined in:
- lib/rmail/serialize.rb
Overview
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, )
}
# Write to a new string string = RMail::Serialize.write(”, message)
Constant Summary collapse
- @@boundary_count =
0
Class Method Summary collapse
-
.write(output, message) ⇒ Object
Serialize a message into a given output object.
Instance Method Summary collapse
-
#initialize(output, escape_from = nil) ⇒ Serialize
constructor
Initialize this Serialize object with an output stream.
-
#serialize(message) ⇒ Object
Serialize a given message into this object’s output object.
Constructor Details
#initialize(output, escape_from = nil) ⇒ Serialize
Initialize this Serialize object with an output stream. If escape_from is not nil, lines with a leading From are escaped.
55 56 57 58 |
# File 'lib/rmail/serialize.rb', line 55 def initialize(output, escape_from = nil) @output = output @escape_from = escape_from end |
Class Method Details
Instance Method Details
#serialize(message) ⇒ Object
Serialize a given message into this object’s output object.
61 62 63 64 |
# File 'lib/rmail/serialize.rb', line 61 def serialize() calculate_boundaries() if .multipart? serialize_low() end |