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
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<=>(other) ⇒ Object
-
#current? ⇒ Boolean
current page or not.
-
#first? ⇒ Boolean
the first page or not.
-
#initialize(options, page, last) ⇒ PageProxy
constructor
:nodoc:.
-
#inside_window? ⇒ Boolean
inside the inner window or not.
-
#last? ⇒ Boolean
the last page or not.
-
#left_outer? ⇒ Boolean
within the left outer window or not.
-
#next? ⇒ Boolean
the next page or not.
-
#number ⇒ Object
the page number.
-
#prev? ⇒ Boolean
the previous page or not.
-
#right_outer? ⇒ Boolean
within the right outer window or not.
- #to_i ⇒ Object
- #to_s ⇒ Object
-
#was_truncated? ⇒ Boolean
The last rendered tag was “truncated” or not.
Constructor Details
#initialize(options, page, last) ⇒ PageProxy
:nodoc:
120 121 122 |
# File 'lib/kaminari/helpers/paginator.rb', line 120 def initialize(, page, last) #:nodoc: @options, @page, @last = , page, last end |
Instance Method Details
#+(other) ⇒ Object
182 183 184 |
# File 'lib/kaminari/helpers/paginator.rb', line 182 def +(other) to_i + other.to_i end |
#-(other) ⇒ Object
186 187 188 |
# File 'lib/kaminari/helpers/paginator.rb', line 186 def -(other) to_i - other.to_i end |
#<=>(other) ⇒ Object
190 191 192 |
# File 'lib/kaminari/helpers/paginator.rb', line 190 def <=>(other) to_i <=> other.to_i end |
#current? ⇒ Boolean
current page or not
130 131 132 |
# File 'lib/kaminari/helpers/paginator.rb', line 130 def current? @page == @options[:current_page] end |
#first? ⇒ Boolean
the first page or not
135 136 137 |
# File 'lib/kaminari/helpers/paginator.rb', line 135 def first? @page == 1 end |
#inside_window? ⇒ Boolean
inside the inner window or not
165 166 167 |
# File 'lib/kaminari/helpers/paginator.rb', line 165 def inside_window? (@options[:current_page] - @page).abs <= @options[:window] end |
#last? ⇒ Boolean
the last page or not
140 141 142 |
# File 'lib/kaminari/helpers/paginator.rb', line 140 def last? @page == @options[:total_pages] end |
#left_outer? ⇒ Boolean
within the left outer window or not
155 156 157 |
# File 'lib/kaminari/helpers/paginator.rb', line 155 def left_outer? @page <= @options[:left] end |
#next? ⇒ Boolean
the next page or not
150 151 152 |
# File 'lib/kaminari/helpers/paginator.rb', line 150 def next? @page == @options[:current_page] + 1 end |
#number ⇒ Object
the page number
125 126 127 |
# File 'lib/kaminari/helpers/paginator.rb', line 125 def number @page end |
#prev? ⇒ Boolean
the previous page or not
145 146 147 |
# File 'lib/kaminari/helpers/paginator.rb', line 145 def prev? @page == @options[:current_page] - 1 end |
#right_outer? ⇒ Boolean
within the right outer window or not
160 161 162 |
# File 'lib/kaminari/helpers/paginator.rb', line 160 def right_outer? @options[:total_pages] - @page < @options[:right] end |
#to_i ⇒ Object
174 175 176 |
# File 'lib/kaminari/helpers/paginator.rb', line 174 def to_i number end |
#to_s ⇒ Object
178 179 180 |
# File 'lib/kaminari/helpers/paginator.rb', line 178 def to_s number.to_s end |
#was_truncated? ⇒ Boolean
The last rendered tag was “truncated” or not
170 171 172 |
# File 'lib/kaminari/helpers/paginator.rb', line 170 def was_truncated? @last.is_a? Gap end |