Class: DHS::Pagination::Link

Inherits:
Base
  • Object
show all
Defined in:
lib/dhs/pagination/link.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_LIMIT

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#current_page, #first_page, #initialize, #last_page, #limit, #limit_value, #next?, #next_offset, #next_page, #offset, page_to_offset, #prev_page, #previous?, #total_pages

Constructor Details

This class inherits a constructor from DHS::Pagination::Base

Instance Method Details

#next(current) ⇒ Object



10
11
12
# File 'lib/dhs/pagination/link.rb', line 10

def next(current)
  current.dig(:next, :href)
end

#pages_leftObject



14
15
16
# File 'lib/dhs/pagination/link.rb', line 14

def pages_left
  pages_left? ? 1 : 0
end

#pages_left?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dhs/pagination/link.rb', line 18

def pages_left?
  data._raw[:next].present?
end

#parallel?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dhs/pagination/link.rb', line 22

def parallel?
  false
end

#totalObject Also known as: count



4
5
6
# File 'lib/dhs/pagination/link.rb', line 4

def total
  data._raw.dig(*_record.items_key).count || 0
end