paginator 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.9 / 2007-02-17
2
+
3
+ * Modified Pager#number_of_pages to support mathn's monkeypatching of Fixnum#/
4
+ * Thanks, Paul King!
5
+
1
6
  == 1.0.8 / 2006-11-02
2
7
 
3
8
  * Added <tt>Page#first_item_number</tt> and <tt>Page#last_item_number</tt>
data/lib/paginator.rb CHANGED
@@ -2,7 +2,7 @@ require 'forwardable'
2
2
 
3
3
  class Paginator
4
4
 
5
- VERSION = '1.0.8'
5
+ VERSION = '1.0.9'
6
6
 
7
7
  class ArgumentError < ::ArgumentError; end
8
8
  class MissingCountError < ArgumentError; end
@@ -29,7 +29,7 @@ class Paginator
29
29
 
30
30
  # Total number of pages
31
31
  def number_of_pages
32
- (@count / @per_page) + (@count % @per_page > 0 ? 1 : 0)
32
+ (@count / @per_page).to_i + (@count % @per_page > 0 ? 1 : 0)
33
33
  end
34
34
 
35
35
  # First page object
@@ -113,11 +113,12 @@ class Paginator
113
113
  @pager.page(@number + 1) if next?
114
114
  end
115
115
 
116
- #
116
+ # The "item number" of the first item on this page
117
117
  def first_item_number
118
118
  1 + @offset
119
119
  end
120
120
 
121
+ # The "item number" of the last item on this page
121
122
  def last_item_number
122
123
  if next?
123
124
  @offset + @pager.per_page
@@ -122,4 +122,13 @@ class PaginatorTest < Test::Unit::TestCase
122
122
  end
123
123
 
124
124
 
125
+ end
126
+
127
+ class PaginatorTestWithMathN < PaginatorTest
128
+
129
+ def setup
130
+ require 'mathn'
131
+ super
132
+ end
133
+
125
134
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: paginator
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.8
7
- date: 2007-01-09 00:00:00 -07:00
6
+ version: 1.0.9
7
+ date: 2007-02-17 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