Class: Zero::Request::Accept
- Inherits:
-
Object
- Object
- Zero::Request::Accept
- 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
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(environment) ⇒ Accept
constructor
create a new accept object.
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
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
25 26 27 |
# File 'lib/zero/request/accept.rb', line 25 def encoding @encoding end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
24 25 26 |
# File 'lib/zero/request/accept.rb', line 24 def language @language end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
23 24 25 |
# File 'lib/zero/request/accept.rb', line 23 def types @types end |