Class: MIME::CompositeMediaType

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

Overview

Composite entities are handled using MIME mechanisms. A MIME processor must handle the body directly. A CompositeMediaType object is composed of one or more CompositeMediaType and/or DiscreteMediaType objects.

This class is abstract.

Direct Known Subclasses

MessageMedia, MultipartMedia

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 MediaType

#to_s

Constructor Details

#initialize(content_type) ⇒ CompositeMediaType

Returns a new instance of CompositeMediaType.



12
13
14
15
16
17
# File 'lib/mime/composite_media_type.rb', line 12

def initialize content_type
  AbstractClassError.no_instantiation(self, CompositeMediaType)

  super(nil, content_type)
  @entities = Array.new
end

Instance Method Details

#add_entity(entity) ⇒ Object

Add a MediaType object to the message.

Raises:



22
23
24
25
# File 'lib/mime/composite_media_type.rb', line 22

def add_entity entity
  raise Error.new('can only add MediaType objects')  unless entity.is_a? MediaType
  @entities.unshift(entity)
end

#attach_entity(entity, params = {}) ⇒ Object

Attach a MediaType object to the message.



30
31
32
33
# File 'lib/mime/composite_media_type.rb', line 30

def attach_entity entity, params = {}
  entity.set_content_disposition('attachment', params)
  add_entity(entity)
end

#inline_entity(entity, params = {}) ⇒ Object

Inline a MediaType object in the message.



38
39
40
41
# File 'lib/mime/composite_media_type.rb', line 38

def inline_entity entity, params = {}
  entity.set_content_disposition('inline', params)
  add_entity(entity)
end