class Vagrant::Util::Mime::Multipart
Attributes
content[RW]
@return [Array<String>] collection of content part of the multipart mime
content_type[RW]
@return [String] type of the content
headers[RW]
@return [Hash] headers for the mime
Public Class Methods
new(content_type="multipart/mixed")
click to toggle source
@param [String] (optional) mime content type @param [String] (optional) mime version
# File lib/vagrant/util/mime.rb, line 20 def initialize(content_type="multipart/mixed") @content_id = "#{Time.now.to_i}@#{SecureRandom.alphanumeric(24)}.local" @boundary = "Boundary_#{SecureRandom.alphanumeric(24)}" @content_type = MIME::Types[content_type].first @content = [] @headers = { "Content-ID"=> "<#{@content_id}>", "Content-Type"=> "#{content_type}; boundary=#{@boundary}", } end
Public Instance Methods
add(entry)
click to toggle source
Add an entry to the multipart mime
@param entry to add
# File lib/vagrant/util/mime.rb, line 34 def add(entry) content << entry end
to_s()
click to toggle source
Output MimeEntity as a string
@return [String] mime data
# File lib/vagrant/util/mime.rb, line 41 def to_s output_string = "" headers.each do |k, v| output_string += "#{k}: #{v}\n" end output_string += "\n--#{@boundary}\n" @content.each do |entry| output_string += entry.to_s output_string += "\n--#{@boundary}\n" end output_string end