class LHS::Pagination::Offset

Constants

DEFAULT_OFFSET

Public Class Methods

next_offset(offset, limit, step = 1) click to toggle source
# File lib/lhs/pagination/offset.rb, line 19
def self.next_offset(offset, limit, step = 1)
  offset.to_i + limit.to_i * step.to_i
end
page_to_offset(page, limit = DEFAULT_LIMIT) click to toggle source
# File lib/lhs/pagination/offset.rb, line 15
def self.page_to_offset(page, limit = DEFAULT_LIMIT)
  (page.to_i - 1) * limit.to_i
end

Public Instance Methods

current_page() click to toggle source
# File lib/lhs/pagination/offset.rb, line 7
def current_page
  (offset + limit) / limit
end
next_offset(step = 1) click to toggle source
# File lib/lhs/pagination/offset.rb, line 11
def next_offset(step = 1)
  self.class.next_offset(offset, limit, step)
end