paginator 1.0.3 → 1.0.4

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.
Files changed (3) hide show
  1. data/README.txt +10 -6
  2. data/lib/paginator.rb +1 -1
  3. metadata +2 -2
data/README.txt CHANGED
@@ -15,14 +15,19 @@ set of objects based on the offset and number of objects per page.
15
15
 
16
16
  == SYNOPSIS:
17
17
 
18
+ In both of these examples I'm using a PER_PAGE constant (the number of items per page), but it's merely for labeling purposes.
19
+
20
+ You could, of course, just pass in the number of items per page directly to the initializer without assigning it somewhere beforehand.
21
+
18
22
  === In a Rails Application
19
23
 
20
- # In your controller
21
- PER_PAGE = 20
22
- @pager = ::Paginator.new(Foo.count, PER_PAGE) do |offset, per_page|
23
- Foo.find(:all, :limit => per_page, :offset => offset)
24
+ def index
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
24
30
  end
25
- @page = @pager.page(params[:page])
26
31
 
27
32
  # In your view
28
33
  <% @page.items.each do |foo| %>
@@ -35,7 +40,6 @@ set of objects based on the offset and number of objects per page.
35
40
  === Anything else
36
41
 
37
42
  bunch_o_data = (1..60).to_a
38
- PER_PAGE = 10
39
43
  pager = Paginator.new(bunch_o_data.size, PER_PAGE) do |offset, per_page|
40
44
  bunch_o_data[offset,per_page]
41
45
  end
data/lib/paginator.rb CHANGED
@@ -2,7 +2,7 @@ require 'forwardable'
2
2
 
3
3
  class Paginator
4
4
 
5
- VERSION = '1.0.3'
5
+ VERSION = '1.0.4'
6
6
 
7
7
  class ArgumentError < ::ArgumentError; end
8
8
  class MissingCountError < ArgumentError; end
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.3
7
- date: 2006-10-25 00:00:00 -06:00
6
+ version: 1.0.4
7
+ date: 2006-10-27 00:00:00 -06:00
8
8
  summary: A generic paginator object for use in any Ruby program
9
9
  require_paths:
10
10
  - lib