Sha256: ec68fad3f0c218570903517af240bfcd95436cfc18cf335a85837be4db199fc2
Contents?: true
Size: 651 Bytes
Versions: 62
Compression:
Stored size: 651 Bytes
Contents
module Workarea class PagedArray < Array attr_reader :items, :page, :per_page, :total def self.from(items, page, per_page, total) new(items, page, per_page, total) end def initialize(items = [], page = 1, per_page = 25, total = 0) @items = items @page = page.to_i @per_page = per_page.to_i @total = total.to_i super(items) end def first_page? page == 1 end def last_page? current_page == total_pages end def total_pages (total / per_page.to_f).ceil end def current_page @page end def total_count total end end end
Version data entries
62 entries across 62 versions & 1 rubygems