Class: Assembla::PageLinks
- Inherits:
-
Object
- Object
- Assembla::PageLinks
- Includes:
- Constants
- Defined in:
- lib/assembla_api/page_links.rb
Overview
Determines the links in the current response link header to be used to find the links to other pages of request responses. These will only be present if the result set size exceeds the per page limit.
Constant Summary collapse
- DELIM_LINKS =
:nodoc:
",".freeze
Constants included from Constants
Constants::ACCEPT, Constants::ACCEPTED_OAUTH_SCOPES, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::OAUTH_SCOPES, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT
Instance Attribute Summary collapse
-
#first ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
-
#last ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
-
#next ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
-
#prev ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
Instance Method Summary collapse
-
#initialize(response_headers) ⇒ PageLinks
constructor
Parses links from executed request.
Constructor Details
#initialize(response_headers) ⇒ PageLinks
Parses links from executed request
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/assembla_api/page_links.rb', line 16 def initialize(response_headers) link_header = response_headers[HEADER_LINK] if link_header return unless link_header =~ /(next|first|last|prev)/ link_header.split(DELIM_LINKS).each do |link| if link.strip =~ /<([^>]+)>; rel=\"([^\"]+)\"/ url_part, = $1, $2 next if !url_part || ! case when META_FIRST self.first = url_part when META_LAST self.last = url_part when META_NEXT self.next = url_part when META_PREV self.prev = url_part end end end else # When on the first page self.next = response_headers[HEADER_NEXT] self.last = response_headers[HEADER_LAST] end end |
Instance Attribute Details
#first ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
12 13 14 |
# File 'lib/assembla_api/page_links.rb', line 12 def first @first end |
#last ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
12 13 14 |
# File 'lib/assembla_api/page_links.rb', line 12 def last @last end |
#next ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
12 13 14 |
# File 'lib/assembla_api/page_links.rb', line 12 def next @next end |
#prev ⇒ Object
Hold the extracted values for URI from the Link header for the first, last, next and previous page.
12 13 14 |
# File 'lib/assembla_api/page_links.rb', line 12 def prev @prev end |