Sha256: 6ba7980d8be96ea0f675747c5606bbc0227e6c89e6dba26cbc331de871545eaa

Contents?: true

Size: 534 Bytes

Versions: 1

Compression:

Stored size: 534 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 last_page?(response_limit, requested_limit)
    offset + response_limit >= total
  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

1 entries across 1 versions & 1 rubygems

Version Path
lhs-20.1.3.pre.paginationfix.3 lib/lhs/pagination/offset.rb