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 Method Summary collapse
- #charset ⇒ Object
-
#initialize(header_value) ⇒ ContentType
constructor
A new instance of ContentType.
- #mime_type ⇒ Object
Constructor Details
#initialize(header_value) ⇒ ContentType
Returns a new instance of ContentType.
290 291 292 |
# File 'lib/httpx/response.rb', line 290 def initialize(header_value) @header_value = header_value end |
Instance Method Details
#charset ⇒ Object
301 302 303 304 305 306 |
# File 'lib/httpx/response.rb', line 301 def charset return @charset if defined?(@charset) m = @header_value.to_s[CHARSET_RE, 1] m && @charset = m.strip.delete('"') end |
#mime_type ⇒ Object
294 295 296 297 298 299 |
# File 'lib/httpx/response.rb', line 294 def mime_type return @mime_type if defined?(@mime_type) m = @header_value.to_s[MIME_TYPE_RE, 1] m && @mime_type = m.strip.downcase end |