Class: HTTP::ContentType
- Inherits:
-
Object
- Object
- HTTP::ContentType
- Defined in:
- lib/http/content_type.rb
Constant Summary collapse
- MIME_TYPE_RE =
%r{^([^/]+/[^;]+)(?:$|;)}
- CHARSET_RE =
/;\s*charset=([^;]+)/i
Instance Attribute Summary collapse
-
#charset ⇒ Object
Returns the value of attribute charset.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
Class Method Summary collapse
-
.parse(str) ⇒ Object
Parse string and return ContentType struct.
Instance Method Summary collapse
-
#initialize(mime_type = nil, charset = nil) ⇒ ContentType
constructor
A new instance of ContentType.
Constructor Details
#initialize(mime_type = nil, charset = nil) ⇒ ContentType
Returns a new instance of ContentType.
29 30 31 32 |
# File 'lib/http/content_type.rb', line 29 def initialize(mime_type = nil, charset = nil) @mime_type = mime_type @charset = charset end |
Instance Attribute Details
#charset ⇒ Object
Returns the value of attribute charset.
8 9 10 |
# File 'lib/http/content_type.rb', line 8 def charset @charset end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
8 9 10 |
# File 'lib/http/content_type.rb', line 8 def mime_type @mime_type end |
Class Method Details
.parse(str) ⇒ Object
Parse string and return ContentType struct
12 13 14 |
# File 'lib/http/content_type.rb', line 12 def parse(str) new mime_type(str), charset(str) end |