Class: MIME::MediaType

Inherits:
Object
  • Object
show all
Includes:
Headers::MIME
Defined in:
lib/mime/media_type.rb

Overview

Abstract top-level media type class.

Direct Known Subclasses

CompositeMediaType, DiscreteMediaType

Instance Attribute Summary collapse

Attributes included from Headers::MIME

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

Instance Method Summary collapse

Constructor Details

#initialize(body, content_type) ⇒ MediaType

Returns a new instance of MediaType.



18
19
20
21
22
23
24
25
# File 'lib/mime/media_type.rb', line 18

def initialize body, content_type
  AbstractClassError.no_instantiation(self, MediaType)

  @headers = HeaderContainer.new
  @body = body
  self.content_id = unique_id
  self.content_type = content_type
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



14
15
16
# File 'lib/mime/media_type.rb', line 14

def headers
  @headers
end

Instance Method Details

#to_sObject

Transform the the MediaType object into a MIME message.



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

def to_s
  "#{headers}\r\n\r\n#{body}"
end