Class: HTTP::Accept::ContentType

Inherits:
MediaTypes::MediaRange show all
Defined in:
lib/http/accept/content_type.rb

Overview

A content type is different from a media range, in that a content type should not have any wild cards.

Instance Attribute Summary

Attributes inherited from MediaTypes::MediaRange

#mime_type, #parameters

Instance Method Summary collapse

Methods inherited from MediaTypes::MediaRange

#===, #parameters_string, parse, parse_parameters, #quality_factor, #split, #to_s

Constructor Details

#initialize(mime_type, parameters = {}) ⇒ ContentType

Returns a new instance of ContentType.

Raises:

  • (ArgumentError)


28
29
30
31
32
33
# File 'lib/http/accept/content_type.rb', line 28

def initialize(mime_type, parameters = {})
	# We do some basic validation here:
	raise ArgumentError.new("#{self.class} can not have wildcards: #{mime_type}") if mime_type.include? '*'
	
	super
end