Sha256: 1a315a8698f25eaff585d600145004d20ed71701c3104884d515f90dcb6a555d
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Gumdrop::Util class Pager attr_reader :all, :pages, :base_path, :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.from({ 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 each_with_index @current_page=1 @pages.each do |page_set| yield page_set, @current_page - 1 @current_page += 1 end @current_page= nil end def [](key) @pages[key] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gumdrop-1.1.1 | lib/gumdrop/util/pager.rb |