Module: ParamsReady::Pagination::AbstractPagination

Included in:
KeysetPagination, OffsetPagination
Defined in:
lib/params_ready/pagination/abstract_pagination.rb

Instance Method Summary collapse

Instance Method Details

#first_pageObject



9
10
11
# File 'lib/params_ready/pagination/abstract_pagination.rb', line 9

def first_page
  update_in(first_page_value, [])
end

#last_page(*args, **opts) ⇒ Object



13
14
15
# File 'lib/params_ready/pagination/abstract_pagination.rb', line 13

def last_page(*args, **opts)
  update_in(last_page_value(*args, **opts), [])
end

#num_pages(count:) ⇒ Object

Raises:



4
5
6
7
# File 'lib/params_ready/pagination/abstract_pagination.rb', line 4

def num_pages(count:)
  raise ParamsReadyError, 'Negative count unexpected' if count < 0
  (count.to_f / limit.to_f).ceil.to_i
end