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

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)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Accept) initialize(environment)

create a new accept object



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

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

- (Object) encoding (readonly)

Returns the value of attribute encoding



33
34
35
# File 'lib/zero/request/accept.rb', line 33

def encoding
  @encoding
end

- (Object) language (readonly)

Returns the value of attribute language



32
33
34
# File 'lib/zero/request/accept.rb', line 32

def language
  @language
end

- (Object) types (readonly)

Returns the value of attribute types



31
32
33
# File 'lib/zero/request/accept.rb', line 31

def types
  @types
end

Class Method Details

+ (Object) map



20
21
22
# File 'lib/zero/request/accept.rb', line 20

def self.map
  @@map ||= {}
end

+ (Object) map=(map)



16
17
18
# File 'lib/zero/request/accept.rb', line 16

def self.map=(map)
  @@map = map
end