class Vagrant::Util::Mime::Entity

Attributes

content[R]

@return [String] entity content

content_type[R]

@return [String] type of the entity content

disposition[RW]

@return [String] content disposition

Public Class Methods

new(content, content_type) click to toggle source

@param [String] entity content @param [String] type of the entity content

# File lib/vagrant/util/mime.rb, line 68
def initialize(content, content_type)
  if !MIME::Types.include?(content_type)
    MIME::Types.add(MIME::Type.new(content_type))
  end
  @content = content
  @content_type = MIME::Types[content_type].first
  @content_id = "#{Time.now.to_i}@#{SecureRandom.alphanumeric(24)}.local"
end

Public Instance Methods

to_s() click to toggle source

Output MimeEntity as a string

@return [String] mime data

# File lib/vagrant/util/mime.rb, line 80
def to_s
  output_string = "Content-ID: <#{@content_id}>\n"
  output_string += "Content-Type: #{@content_type}\n"
  if disposition
    output_string += "Content-Disposition: #{@disposition}\n"
  end
  output_string += "\n#{content}"
  output_string
end