Class: Hexabat::PageRange::LinkHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/hexabat/page_range.rb

Constant Summary collapse

PREV =
/<https:\/\/\S+\?page=(?'prev_page'\d+)[\S]+>; rel="prev"/
LAST =
/<https:\/\/\S+\?page=(?'last_page'\d+)[\S]+>; rel="last"/

Instance Method Summary collapse

Constructor Details

#initialize(header) ⇒ LinkHeader

Returns a new instance of LinkHeader.



14
15
16
# File 'lib/hexabat/page_range.rb', line 14

def initialize(header)
  @header = header
end

Instance Method Details

#lastObject



18
19
20
21
# File 'lib/hexabat/page_range.rb', line 18

def last
  return prev.succ if last_missing? or last_incorrect?
  return header_last
end

#prevObject



23
24
25
# File 'lib/hexabat/page_range.rb', line 23

def prev
  @prev ||= extract(PREV)
end