Class: MIME::MediaType
- Inherits:
-
Object
- Object
- MIME::MediaType
- Includes:
- Headers::MIME
- Defined in:
- lib/mime/media_type.rb
Overview
Abstract top-level media type class.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Attributes included from Headers::MIME
#content_description, #content_disposition, #content_id, #content_transfer_encoding, #content_type, #mime_version
Instance Method Summary collapse
-
#initialize(body, content_type, content_params = {}) ⇒ MediaType
constructor
A new instance of MediaType.
-
#to_s ⇒ Object
Transform the the MediaType object into a MIME message.
Constructor Details
#initialize(body, content_type, content_params = {}) ⇒ MediaType
Returns a new instance of MediaType.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mime/media_type.rb', line 18 def initialize body, content_type, content_params = {} AbstractClassError.no_instantiation(self, MediaType) @headers = HeaderContainer.new @body = body self.content_id = unique_id self.content_type = if content_params.empty? content_type else params = content_params.to_a.map {|kv| kv.join('=')}.join('; ') "#{content_type}; #{params}" end end |
Instance Attribute Details
#headers ⇒ Object (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_s ⇒ Object
Transform the the MediaType object into a MIME message.
36 37 38 |
# File 'lib/mime/media_type.rb', line 36 def to_s "#{headers}\r\n\r\n#{body}" end |