Class: Zero::Request::AcceptType
- Inherits:
-
Object
- Object
- Zero::Request::AcceptType
- Defined in:
- lib/zero/request/accept_type.rb
Overview
This class provides an interface to access information of accept schemas.
Constant Summary collapse
- MEDIA_TYPE_SEPERATOR =
','
- MEDIA_PARAM_SEPERATOR =
';'
- MEDIA_QUALITY_REGEX =
/q=[01]\./
Instance Method Summary collapse
-
#each ⇒ Object
iterate over all media types.
-
#initialize(string) ⇒ AcceptType
constructor
create a new instance of AcceptType.
-
#preferred ⇒ Object
return the preferred type.
Constructor Details
#initialize(string) ⇒ AcceptType
create a new instance of AcceptType
10 11 12 13 14 15 16 |
# File 'lib/zero/request/accept_type.rb', line 10 def initialize(string) if string.nil? @elements = [] else @elements = parse_elements(string) end end |
Instance Method Details
#each ⇒ Object
iterate over all media types
25 26 27 |
# File 'lib/zero/request/accept_type.rb', line 25 def each @elements.each {|element| yield element} end |
#preferred ⇒ Object
return the preferred type
20 21 22 |
# File 'lib/zero/request/accept_type.rb', line 20 def preferred @elements.first end |