Sha256: d6b9994f83c7fb17c887a9f027239b5befb7ffb5cd4e7e1a756ce6f745fa9cce

Contents?: true

Size: 440 Bytes

Versions: 75

Compression:

Stored size: 440 Bytes

Contents

# frozen_string_literal: true

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

75 entries across 75 versions & 1 rubygems

Version Path
lhs-19.2.0 lib/lhs/pagination/offset.rb
lhs-19.1.0 lib/lhs/pagination/offset.rb
lhs-19.0.2 lib/lhs/pagination/offset.rb
lhs-19.0.1 lib/lhs/pagination/offset.rb
lhs-19.0.0 lib/lhs/pagination/offset.rb
lhs-19.0.0.pre.endpoint.1 lib/lhs/pagination/offset.rb
lhs-18.0.3 lib/lhs/pagination/offset.rb
lhs-18.0.2 lib/lhs/pagination/offset.rb
lhs-18.0.1 lib/lhs/pagination/offset.rb
lhs-18.0.0 lib/lhs/pagination/offset.rb
lhs-17.0.1 lib/lhs/pagination/offset.rb
lhs-17.0.1.pre1 lib/lhs/pagination/offset.rb
lhs-18.0.0.pre.pre1 lib/lhs/pagination/offset.rb
lhs-17.0.0 lib/lhs/pagination/offset.rb
lhs-16.1.6 lib/lhs/pagination/offset.rb