Class: ChupaText::Formatters::MIME
- Defined in:
- lib/chupa-text/formatters/mime.rb
Instance Method Summary collapse
-
#format_finish(data) ⇒ Object
-
#initialize(output, options = {}) ⇒ MIME
constructor
A new instance of MIME.
Methods inherited from Hash
#format_extracted, #format_start
Constructor Details
#initialize(output, options = {}) ⇒ MIME
Returns a new instance of MIME.
25 26 27 28 29 |
# File 'lib/chupa-text/formatters/mime.rb', line 25 def initialize(output, ={}) super() @output = output @boundary = [:boundary] end |
Instance Method Details
#format_finish(data) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chupa-text/formatters/mime.rb', line 31 def format_finish(data) formatted = super @output << "MIME-Version: 1.0\r\n" format_hash(formatted, ["texts"]) texts = formatted["texts"] boundary = @boundary || Digest::SHA1.hexdigest(data.uri.to_s) @output << "Content-Type: multipart/mixed; boundary=#{boundary}\r\n" texts.each do |text| @output << "\r\n--#{boundary}\r\n" format_text(text) end @output << "\r\n--#{boundary}--\r\n" end |