Sha256: 4ed5397140cf7bf8c0f1ae5c78ed9ff37eee94e7769e74ef66399312cebb198d

Contents?: true

Size: 447 Bytes

Versions: 75

Compression:

Stored size: 447 Bytes

Contents

# frozen_string_literal: true

class LHS::Pagination::Start < LHS::Pagination::Base

  DEFAULT_OFFSET = 1

  def current_page
    (offset + limit - 1) / 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 + 1
  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-26.2.0 lib/lhs/pagination/start.rb
lhs-26.1.0 lib/lhs/pagination/start.rb
lhs-26.0.1 lib/lhs/pagination/start.rb
lhs-26.0.0 lib/lhs/pagination/start.rb
lhs-25.2.0 lib/lhs/pagination/start.rb
lhs-25.1.0 lib/lhs/pagination/start.rb
lhs-25.0.4 lib/lhs/pagination/start.rb
lhs-25.0.3 lib/lhs/pagination/start.rb
lhs-25.0.2 lib/lhs/pagination/start.rb
lhs-25.0.1 lib/lhs/pagination/start.rb
lhs-25.0.0 lib/lhs/pagination/start.rb
lhs-24.1.2 lib/lhs/pagination/start.rb
lhs-24.1.1 lib/lhs/pagination/start.rb
lhs-24.1.0 lib/lhs/pagination/start.rb
lhs-24.1.0.pre.2 lib/lhs/pagination/start.rb
lhs-24.1.0.pre.1 lib/lhs/pagination/start.rb
lhs-24.0.0 lib/lhs/pagination/start.rb
lhs-23.0.2 lib/lhs/pagination/start.rb
lhs-23.0.1 lib/lhs/pagination/start.rb
lhs-23.0.0 lib/lhs/pagination/start.rb