Sha256: 0ce208787e6c2a0bb5a9d8632ade32f0a85a72b1e1e88eb82c07c83032dde8d0

Contents?: true

Size: 416 Bytes

Versions: 55

Compression:

Stored size: 416 Bytes

Contents

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

55 entries across 55 versions & 1 rubygems

Version Path
lhs-16.1.5 lib/lhs/pagination/start.rb
lhs-16.1.4 lib/lhs/pagination/start.rb
lhs-16.1.3 lib/lhs/pagination/start.rb
lhs-16.1.2 lib/lhs/pagination/start.rb
lhs-16.1.1 lib/lhs/pagination/start.rb
lhs-16.1.0 lib/lhs/pagination/start.rb
lhs-16.0.1 lib/lhs/pagination/start.rb
lhs-16.0.0 lib/lhs/pagination/start.rb
lhs-15.7.0 lib/lhs/pagination/start.rb
lhs-15.6.1 lib/lhs/pagination/start.rb
lhs-15.6.0 lib/lhs/pagination/start.rb
lhs-15.5.1 lib/lhs/pagination/start.rb
lhs-15.5.0 lib/lhs/pagination/start.rb
lhs-15.4.1 lib/lhs/pagination/start.rb
lhs-15.4.0 lib/lhs/pagination/start.rb
lhs-15.4.0.pre.hasone.1 lib/lhs/pagination/start.rb
lhs-15.3.3 lib/lhs/pagination/start.rb
lhs-15.3.3.pre.fixoptions.1 lib/lhs/pagination/start.rb
lhs-15.3.2 lib/lhs/pagination/start.rb
lhs-15.3.1 lib/lhs/pagination/start.rb