Class: Kaminari::Helpers::Paginator::PageProxy
- Inherits:
-
Object
- Object
- Kaminari::Helpers::Paginator::PageProxy
- Includes:
- Comparable
- Defined in:
- lib/kaminari/helpers/paginator.rb
Overview
Wraps a "page number" and provides some utility methods
Instance Method Summary (collapse)
- - (Object) +(other)
- - (Object) -(other)
- - (Object) <=>(other)
-
- (Boolean) current?
current page or not.
-
- (Boolean) first?
the first page or not.
-
- (PageProxy) initialize(options, page, last)
constructor
:nodoc:.
-
- (Boolean) inside_window?
inside the inner window or not.
-
- (Boolean) last?
the last page or not.
-
- (Boolean) left_outer?
within the left outer window or not.
-
- (Boolean) next?
the next page or not.
-
- (Object) number
the page number.
-
- (Boolean) prev?
the previous page or not.
-
- (Boolean) right_outer?
within the right outer window or not.
- - (Object) to_i
- - (Object) to_s
-
- (Boolean) was_truncated?
The last rendered tag was "truncated" or not.
Constructor Details
- (PageProxy) initialize(options, page, last)
:nodoc:
99 100 101 |
# File 'lib/kaminari/helpers/paginator.rb', line 99 def initialize(, page, last) #:nodoc: @options, @page, @last = , page, last end |
Instance Method Details
- (Object) +(other)
161 162 163 |
# File 'lib/kaminari/helpers/paginator.rb', line 161 def +(other) to_i + other.to_i end |
- (Object) -(other)
165 166 167 |
# File 'lib/kaminari/helpers/paginator.rb', line 165 def -(other) to_i - other.to_i end |
- (Object) <=>(other)
169 170 171 |
# File 'lib/kaminari/helpers/paginator.rb', line 169 def <=>(other) to_i <=> other.to_i end |
- (Boolean) current?
current page or not
109 110 111 |
# File 'lib/kaminari/helpers/paginator.rb', line 109 def current? @page == @options[:current_page] end |
- (Boolean) first?
the first page or not
114 115 116 |
# File 'lib/kaminari/helpers/paginator.rb', line 114 def first? @page == 1 end |
- (Boolean) inside_window?
inside the inner window or not
144 145 146 |
# File 'lib/kaminari/helpers/paginator.rb', line 144 def inside_window? (@options[:current_page] - @page).abs <= @options[:window] end |
- (Boolean) last?
the last page or not
119 120 121 |
# File 'lib/kaminari/helpers/paginator.rb', line 119 def last? @page == @options[:total_pages] end |
- (Boolean) left_outer?
within the left outer window or not
134 135 136 |
# File 'lib/kaminari/helpers/paginator.rb', line 134 def left_outer? @page <= @options[:left] end |
- (Boolean) next?
the next page or not
129 130 131 |
# File 'lib/kaminari/helpers/paginator.rb', line 129 def next? @page == @options[:current_page] + 1 end |
- (Object) number
the page number
104 105 106 |
# File 'lib/kaminari/helpers/paginator.rb', line 104 def number @page end |
- (Boolean) prev?
the previous page or not
124 125 126 |
# File 'lib/kaminari/helpers/paginator.rb', line 124 def prev? @page == @options[:current_page] - 1 end |
- (Boolean) right_outer?
within the right outer window or not
139 140 141 |
# File 'lib/kaminari/helpers/paginator.rb', line 139 def right_outer? @options[:total_pages] - @page < @options[:right] end |
- (Object) to_i
153 154 155 |
# File 'lib/kaminari/helpers/paginator.rb', line 153 def to_i number end |
- (Object) to_s
157 158 159 |
# File 'lib/kaminari/helpers/paginator.rb', line 157 def to_s number.to_s end |
- (Boolean) was_truncated?
The last rendered tag was "truncated" or not
149 150 151 |
# File 'lib/kaminari/helpers/paginator.rb', line 149 def was_truncated? @last.is_a? Gap end |