Sha256: 363741218e64adb91efe0b654abce395f5ae7c4486476d249f25dbf5fd362001

Contents?: true

Size: 508 Bytes

Versions: 22

Compression:

Stored size: 508 Bytes

Contents

class Que::Web::Pager
  attr_reader :current_page, :page_size, :total, :page_count

  def initialize(page_no, page_size, total)
    @current_page = page_no > 1 ? page_no : 1
    @page_size = page_size
    @total = total

    @page_count = total > 0 ? (total / page_size.to_f).ceil : 1
  end

  def next_page
    @current_page < @page_count ? (@current_page + 1) : nil
  end

  def prev_page
    @current_page > 1 ? (@current_page - 1) : nil
  end

  def offset
    (@current_page - 1) * @page_size
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
que-web-0.10.0 lib/que/web/pager.rb
que-web-0.9.4 lib/que/web/pager.rb
que-web-0.9.3 lib/que/web/pager.rb
que-web-0.9.2 lib/que/web/pager.rb
que-web-0.9.1 lib/que/web/pager.rb
que-web-0.9.0 lib/que/web/pager.rb
que-web-0.8.0 lib/que/web/pager.rb
que-web-0.7.2 lib/que/web/pager.rb
que-web-0.7.1 lib/que/web/pager.rb
que-web-0.7.0 lib/que/web/pager.rb
que-web-0.6.3 lib/que/web/pager.rb
que-web-0.6.2 lib/que/web/pager.rb
que-web-0.6.1 lib/que/web/pager.rb
que-web-0.6.0 lib/que/web/pager.rb
que-web-0.5.0 lib/que/web/pager.rb
que-web-0.4.0 lib/que/web/pager.rb
que-web-0.3.2 lib/que/web/pager.rb
que-web-0.3.1 lib/que/web/pager.rb
que-web-0.3.0 lib/que/web/pager.rb
que-web-0.2.2 lib/que/web/pager.rb