Class: ActionSet::Helpers::Paginator::PageInterface
- Inherits:
-
Object
- Object
- ActionSet::Helpers::Paginator::PageInterface
- Defined in:
- lib/action_set/helpers/paginator.rb
Overview
Wraps a “page number” and provides some utility methods
Instance Method Summary collapse
- #current? ⇒ Boolean
- #first? ⇒ Boolean
-
#initialize(page, info) ⇒ PageInterface
constructor
A new instance of PageInterface.
- #last? ⇒ Boolean
- #next? ⇒ Boolean
- #number ⇒ Object
- #out_of_range? ⇒ Boolean
- #prev? ⇒ Boolean
- #rel ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(page, info) ⇒ PageInterface
Returns a new instance of PageInterface.
116 117 118 119 |
# File 'lib/action_set/helpers/paginator.rb', line 116 def initialize(page, info) @page = page @info = info end |
Instance Method Details
#current? ⇒ Boolean
125 126 127 |
# File 'lib/action_set/helpers/paginator.rb', line 125 def current? @page == @info[:current_page] end |
#first? ⇒ Boolean
129 130 131 |
# File 'lib/action_set/helpers/paginator.rb', line 129 def first? @page == 1 end |
#last? ⇒ Boolean
133 134 135 |
# File 'lib/action_set/helpers/paginator.rb', line 133 def last? @page == @info[:total_pages] end |
#next? ⇒ Boolean
141 142 143 |
# File 'lib/action_set/helpers/paginator.rb', line 141 def next? @page == @info[:current_page] + 1 end |
#number ⇒ Object
121 122 123 |
# File 'lib/action_set/helpers/paginator.rb', line 121 def number @page end |
#out_of_range? ⇒ Boolean
151 152 153 |
# File 'lib/action_set/helpers/paginator.rb', line 151 def out_of_range? @page > @info[:total_pages] end |
#prev? ⇒ Boolean
137 138 139 |
# File 'lib/action_set/helpers/paginator.rb', line 137 def prev? @page == @info[:current_page] - 1 end |
#rel ⇒ Object
145 146 147 148 149 |
# File 'lib/action_set/helpers/paginator.rb', line 145 def rel return 'next' if next? return 'prev' if prev? nil end |
#to_i ⇒ Object
155 156 157 |
# File 'lib/action_set/helpers/paginator.rb', line 155 def to_i number end |
#to_s ⇒ Object
159 160 161 |
# File 'lib/action_set/helpers/paginator.rb', line 159 def to_s number.to_s end |