class Camper::PaginationData
Constants
- DELIM_LINKS
- HEADER_LINK
- HEADER_TOTAL_COUNT
- LINK_REGEX
- METAS
Attributes
total_count[RW]
Public Class Methods
new(headers)
click to toggle source
# File lib/camper/pagination_data.rb, line 17 def initialize(headers) link_header = headers[HEADER_LINK] @total_count = headers[HEADER_TOTAL_COUNT].to_i extract_links(link_header) if link_header && link_header =~ /(next)/ end
Public Instance Methods
inspect()
click to toggle source
# File lib/camper/pagination_data.rb, line 25 def inspect "Next URL: #{@next}; Total Count: #{@total_count}" end
Private Instance Methods
extract_links(header)
click to toggle source
# File lib/camper/pagination_data.rb, line 31 def extract_links(header) header.split(DELIM_LINKS).each do |link| LINK_REGEX.match(link.strip) do |match| url = match[1] meta = match[2] next if !url || !meta || METAS.index(meta).nil? send("#{meta}=", url) end end end