Class: HTTPX::ContentType

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/response.rb

Constant Summary collapse

MIME_TYPE_RE =
%r{^([^/]+/[^;]+)(?:$|;)}
CHARSET_RE =
/;\s*charset=([^;]+)/i

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mime_type, charset) ⇒ ContentType

Returns a new instance of ContentType.



196
197
198
199
# File 'lib/httpx/response.rb', line 196

def initialize(mime_type, charset)
  @mime_type = mime_type
  @charset = charset
end

Instance Attribute Details

#charsetObject (readonly)

Returns the value of attribute charset.



194
195
196
# File 'lib/httpx/response.rb', line 194

def charset
  @charset
end

#mime_typeObject (readonly)

Returns the value of attribute mime_type.



194
195
196
# File 'lib/httpx/response.rb', line 194

def mime_type
  @mime_type
end

Class Method Details

.parse(str) ⇒ Object

Parse string and return ContentType struct



203
204
205
# File 'lib/httpx/response.rb', line 203

def parse(str)
  new(mime_type(str), charset(str))
end