Sha256: 71a7b13ccbe07cb71c5a29f815d0ea51482559709e9d4e9be4c7026d4e1a46ba

Contents?: true

Size: 409 Bytes

Versions: 55

Compression:

Stored size: 409 Bytes

Contents

class LHS::Pagination::Offset < LHS::Pagination::Base

  DEFAULT_OFFSET = 0

  def current_page
    (offset + limit) / limit
  end

  def next_offset(step = 1)
    self.class.next_offset(offset, limit, step)
  end

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

  def self.next_offset(offset, limit, step = 1)
    offset.to_i + limit.to_i * step.to_i
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
lhs-14.6.0 lib/lhs/pagination/offset.rb
lhs-14.5.0 lib/lhs/pagination/offset.rb
lhs-14.4.0 lib/lhs/pagination/offset.rb
lhs-14.3.4 lib/lhs/pagination/offset.rb
lhs-14.3.3 lib/lhs/pagination/offset.rb
lhs-14.3.2 lib/lhs/pagination/offset.rb
lhs-14.3.1 lib/lhs/pagination/offset.rb
lhs-14.3.0 lib/lhs/pagination/offset.rb
lhs-14.2.0 lib/lhs/pagination/offset.rb
lhs-14.1.1 lib/lhs/pagination/offset.rb
lhs-14.1.0 lib/lhs/pagination/offset.rb
lhs-14.0.3 lib/lhs/pagination/offset.rb
lhs-14.0.2 lib/lhs/pagination/offset.rb
lhs-14.0.1 lib/lhs/pagination/offset.rb
lhs-14.0.0 lib/lhs/pagination/offset.rb