Class: HTTPX::ContentType
- Inherits:
-
Object
- Object
- HTTPX::ContentType
- Defined in:
- lib/httpx/response.rb
Constant Summary collapse
- MIME_TYPE_RE =
%r{^([^/]+/[^;]+)(?:$|;)}.freeze
- CHARSET_RE =
/;\s*charset=([^;]+)/i.freeze
Instance Attribute Summary collapse
-
#charset ⇒ Object
readonly
Returns the value of attribute charset.
-
#mime_type ⇒ Object
readonly
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, charset) ⇒ ContentType
constructor
A new instance of ContentType.
Constructor Details
#initialize(mime_type, charset) ⇒ ContentType
Returns a new instance of ContentType.
229 230 231 232 |
# File 'lib/httpx/response.rb', line 229 def initialize(mime_type, charset) @mime_type = mime_type @charset = charset end |
Instance Attribute Details
#charset ⇒ Object (readonly)
Returns the value of attribute charset.
227 228 229 |
# File 'lib/httpx/response.rb', line 227 def charset @charset end |
#mime_type ⇒ Object (readonly)
Returns the value of attribute mime_type.
227 228 229 |
# File 'lib/httpx/response.rb', line 227 def mime_type @mime_type end |
Class Method Details
.parse(str) ⇒ Object
Parse string and return ContentType struct
236 237 238 |
# File 'lib/httpx/response.rb', line 236 def parse(str) new(mime_type(str), charset(str)) end |