Class: LHS::Pagination::Offset

Inherits:
Base
  • Object
show all
Defined in:
lib/lhs/pagination/offset.rb

Constant Summary

Constants inherited from Base

Base::DEFAULT_LIMIT

Instance Attribute Summary

Attributes inherited from Base

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#count, #first_page, #initialize, #last_page, #limit, #limit_value, #next?, #next_page, #offset, #pages_left, #prev_page, #previous?, #total, #total_pages

Constructor Details

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

Class Method Details

.page_to_offset(page, limit = DEFAULT_LIMIT) ⇒ Object



11
12
13
# File 'lib/lhs/pagination/offset.rb', line 11

def self.page_to_offset(page, limit = DEFAULT_LIMIT)
  (page.to_i - 1) * limit.to_i
end

Instance Method Details

#current_pageObject



3
4
5
# File 'lib/lhs/pagination/offset.rb', line 3

def current_page
  (offset + limit) / limit
end

#next_offset(step = 1) ⇒ Object



7
8
9
# File 'lib/lhs/pagination/offset.rb', line 7

def next_offset(step = 1)
  offset + limit * step
end