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.
326 327 328 |
# File 'lib/httpx/response.rb', line 326 def initialize(header_value) @header_value = header_value end |
Instance Method Details
#charset ⇒ Object
337 338 339 340 341 342 |
# File 'lib/httpx/response.rb', line 337 def charset return @charset if defined?(@charset) m = @header_value.to_s[CHARSET_RE, 1] m && @charset = m.strip.delete('"') end |
#mime_type ⇒ Object
330 331 332 333 334 335 |
# File 'lib/httpx/response.rb', line 330 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 |