Class: MIME::MultipartMedia

Inherits:
CompositeMediaType show all
Defined in:
lib/mime/composite_media_type.rb

Overview

The abstract base class for all multipart message subtypes. The entities of a multipart message are delimited by a unique boundary.

Direct Known Subclasses

Alternative, FormData, Mixed, Related

Defined Under Namespace

Classes: Alternative, FormData, Mixed, Related

Instance Attribute Summary

Attributes inherited from MediaType

#headers

Attributes included from Headers::MIME

#content_description, #content_disposition, #content_id, #content_transfer_encoding, #content_type, #mime_version

Instance Method Summary collapse

Methods inherited from CompositeMediaType

#add_entity, #attach_entity, #inline_entity

Methods inherited from MediaType

#to_s

Constructor Details

#initialize(content_type) ⇒ MultipartMedia

Returns a new instance of MultipartMedia.



61
62
63
64
# File 'lib/mime/composite_media_type.rb', line 61

def initialize content_type
  AbstractClassError.no_instantiation(self, MultipartMedia)
  super
end

Instance Method Details

#bodyObject

Return the multipart representation of the body.



76
77
78
79
# File 'lib/mime/composite_media_type.rb', line 76

def body
  all_entities = @entities.join("\r\n--#{boundary}\r\n")
  "--#{boundary}\r\n#{all_entities}\r\n--#{boundary}--\r\n"
end

#boundaryObject

The boundary used to separate the message entities.



69
70
71
# File 'lib/mime/composite_media_type.rb', line 69

def boundary
  @boundary ||= "Boundary_#{unique_id}"
end