Sha256: 11313f9c7c41cd317546e21a0cc5c9ee6f89b4d3864cfd19e253cc0ed2ad2ee7
Contents?: true
Size: 945 Bytes
Versions: 14
Compression:
Stored size: 945 Bytes
Contents
module Gumdrop class Pager attr_reader :all, :pages, :base_url, :current_page, :page_sets def initialize(articles, base_path="/page", page_size=5) @all= articles @page_size= page_size @base_path= base_path @page_sets= @all.in_groups_of(page_size, false) @pages= [] @current_page=1 @page_sets.each do |art_ary| @pages << HashObject.new({ items: art_ary, page: @current_page, uri: "#{base_path}/#{current_page}", pager: self }) @current_page += 1 end @current_page= nil end def length @pages.length end def first @pages.first end def last @pages.last end def each @current_page=1 @pages.each do |page_set| yield page_set @current_page += 1 end @current_page= nil end def [](key) @pages[key] end end end
Version data entries
14 entries across 14 versions & 1 rubygems