Class: BootstrapPager::Helpers::Paginator::PageProxy
- Inherits:
-
Object
- Object
- BootstrapPager::Helpers::Paginator::PageProxy
- Includes:
- Comparable
- Defined in:
- lib/bootstrap_pager/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:
110 111 112 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 110 def initialize(, page, last) #:nodoc: @options, @page, @last = , page, last end |
Instance Method Details
#+(other) ⇒ Object
172 173 174 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 172 def +(other) to_i + other.to_i end |
#-(other) ⇒ Object
176 177 178 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 176 def -(other) to_i - other.to_i end |
#<=>(other) ⇒ Object
180 181 182 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 180 def <=>(other) to_i <=> other.to_i end |
#current? ⇒ Boolean
current page or not
120 121 122 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 120 def current? @page == @options[:current_page] end |
#first? ⇒ Boolean
the first page or not
125 126 127 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 125 def first? @page == 1 end |
#inside_window? ⇒ Boolean
inside the inner window or not
155 156 157 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 155 def inside_window? (@options[:current_page] - @page).abs <= @options[:window] end |
#last? ⇒ Boolean
the last page or not
130 131 132 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 130 def last? @page == @options[:total_pages] end |
#left_outer? ⇒ Boolean
within the left outer window or not
145 146 147 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 145 def left_outer? @page <= @options[:left] end |
#next? ⇒ Boolean
the next page or not
140 141 142 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 140 def next? @page == @options[:current_page] + 1 end |
#number ⇒ Object
the page number
115 116 117 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 115 def number @page end |
#prev? ⇒ Boolean
the previous page or not
135 136 137 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 135 def prev? @page == @options[:current_page] - 1 end |
#right_outer? ⇒ Boolean
within the right outer window or not
150 151 152 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 150 def right_outer? @options[:total_pages] - @page < @options[:right] end |
#to_i ⇒ Object
164 165 166 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 164 def to_i number end |
#to_s ⇒ Object
168 169 170 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 168 def to_s number.to_s end |
#was_truncated? ⇒ Boolean
The last rendered tag was “truncated” or not
160 161 162 |
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 160 def was_truncated? @last.is_a? Gap end |