Class: Zero::Request::Accept

Inherits:
Object
  • Object
show all
Defined in:
lib/zero/request/accept.rb

Overview

encapsulates the accept header to easier work with this is partly copied from sinatra

Constant Summary collapse

MEDIA_TYPE_SEPERATOR =
','
MEDIA_PARAM_SEPERATOR =
';'
MEDIA_QUALITY_REGEX =
/q=[01]\./
KEY_HTTP_ACCEPT =
'HTTP_ACCEPT'
KEY_HTTP_ACCEPT_LANGUAGE =
'HTTP_ACCEPT_LANGUAGE'
KEY_HTTP_ACCEPT_ENCODING =
'HTTP_ACCEPT_ENCODING'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Accept

create a new accept object



17
18
19
20
21
# File 'lib/zero/request/accept.rb', line 17

def initialize(environment)
  @types = AcceptType.new(environment[KEY_HTTP_ACCEPT])
  @language = AcceptType.new(environment[KEY_HTTP_ACCEPT_LANGUAGE])
  @encoding = AcceptType.new(environment[KEY_HTTP_ACCEPT_ENCODING])
end

Instance Attribute Details

#encodingObject (readonly)

Returns the value of attribute encoding.



25
26
27
# File 'lib/zero/request/accept.rb', line 25

def encoding
  @encoding
end

#languageObject (readonly)

Returns the value of attribute language.



24
25
26
# File 'lib/zero/request/accept.rb', line 24

def language
  @language
end

#typesObject (readonly)

Returns the value of attribute types.



23
24
25
# File 'lib/zero/request/accept.rb', line 23

def types
  @types
end