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

#parameters, #subtype, #type

Instance Method Summary collapse

Methods inherited from MediaTypes::MediaRange

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

Constructor Details

#initialize(type, subtype, parameters = {}) ⇒ ContentType

Returns a new instance of ContentType.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
# File 'lib/http/accept/content_type.rb', line 13

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