class ChupaText::Formatters::MIME
Public Class Methods
Source
# File lib/chupa-text/formatters/mime.rb, line 25 def initialize(output, options={}) super() @output = output @boundary = options[:boundary] end
Calls superclass method
ChupaText::Formatters::Hash::new
Public Instance Methods
Source
# 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
Calls superclass method
ChupaText::Formatters::Hash#format_finish
Private Instance Methods
Source
# File lib/chupa-text/formatters/mime.rb, line 47 def format_hash(hash, ignore_keys) hash.each do |key, value| next if ignore_keys.include?(key) @output << "#{key}: #{value}\r\n" end end
Source
# File lib/chupa-text/formatters/mime.rb, line 54 def format_text(hash) format_hash(hash, ["body"]) body = hash["body"] if body @output << "\r\n" @output << body end end