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
- MEDIA_TYPE_SEPERATOR =
','
- MEDIA_PARAM_SEPERATOR =
';'
- MEDIA_QUALITY_REGEX =
/q=[01]\./
Instance Method Summary (collapse)
-
- (Object) each
iterate over all media types.
-
- (AcceptType) initialize(string)
constructor
create a new instance of AcceptType.
-
- (Object) preferred
return the preferred type.
Constructor Details
- (AcceptType) initialize(string)
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
- (Object) each
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 |
- (Object) preferred
return the preferred type
20 21 22 |
# File 'lib/zero/request/accept_type.rb', line 20 def preferred @elements.first end |