paginator 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.txt +13 -13
- data/lib/paginator.rb +2 -2
- metadata +2 -2
data/README.txt
CHANGED
@@ -22,11 +22,11 @@ You could, of course, just pass in the number of items per page directly to the
|
|
22
22
|
=== In a Rails Application
|
23
23
|
|
24
24
|
def index
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
@pager = ::Paginator.new(Foo.count, PER_PAGE) do |offset, per_page|
|
26
|
+
Foo.find(:all, :limit => per_page, :offset => offset)
|
27
|
+
end
|
28
|
+
@page = @pager.page(params[:page])
|
29
|
+
# respond_to here if you want it
|
30
30
|
end
|
31
31
|
|
32
32
|
# In your view
|
@@ -40,15 +40,15 @@ You could, of course, just pass in the number of items per page directly to the
|
|
40
40
|
=== Anything else
|
41
41
|
|
42
42
|
bunch_o_data = (1..60).to_a
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
pager = Paginator.new(bunch_o_data.size, PER_PAGE) do |offset, per_page|
|
44
|
+
bunch_o_data[offset,per_page]
|
45
|
+
end
|
46
|
+
pager.each do |page|
|
47
|
+
puts "Page ##{page.number}"
|
48
|
+
page.each do |item|
|
49
|
+
puts item
|
50
50
|
end
|
51
|
-
|
51
|
+
end
|
52
52
|
|
53
53
|
== REQUIREMENTS:
|
54
54
|
|
data/lib/paginator.rb
CHANGED
@@ -2,13 +2,13 @@ require 'forwardable'
|
|
2
2
|
|
3
3
|
class Paginator
|
4
4
|
|
5
|
-
VERSION = '1.0.
|
5
|
+
VERSION = '1.0.7'
|
6
6
|
|
7
7
|
class ArgumentError < ::ArgumentError; end
|
8
8
|
class MissingCountError < ArgumentError; end
|
9
9
|
class MissingSelectError < ArgumentError; end
|
10
10
|
|
11
|
-
attr_reader :per_page
|
11
|
+
attr_reader :per_page, :count
|
12
12
|
|
13
13
|
# Instantiate a new Paginator object
|
14
14
|
#
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: paginator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2006-11-
|
6
|
+
version: 1.0.7
|
7
|
+
date: 2006-11-29 00:00:00 -07:00
|
8
8
|
summary: A generic paginator object for use in any Ruby program
|
9
9
|
require_paths:
|
10
10
|
- lib
|