Class: DHS::Pagination::Start
- Inherits:
-
Base
- Object
- Base
- DHS::Pagination::Start
show all
- Defined in:
- lib/dhs/pagination/start.rb
Constant Summary
collapse
- DEFAULT_OFFSET =
1
Constants inherited
from Base
Base::DEFAULT_LIMIT
Instance Attribute Summary
Attributes inherited from Base
#data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#first_page, #initialize, #last_page, #limit, #limit_value, #next?, #next_page, #offset, #pages_left, #pages_left?, #parallel?, #prev_page, #previous?, #total, #total_pages
Class Method Details
.next_offset(offset, limit, step = 1) ⇒ Object
19
20
21
|
# File 'lib/dhs/pagination/start.rb', line 19
def self.next_offset(offset, limit, step = 1)
offset.to_i + limit.to_i * step.to_i
end
|
.page_to_offset(page, limit = DEFAULT_LIMIT) ⇒ Object
15
16
17
|
# File 'lib/dhs/pagination/start.rb', line 15
def self.page_to_offset(page, limit = DEFAULT_LIMIT)
(page.to_i - 1) * limit.to_i + 1
end
|
Instance Method Details
#current_page ⇒ Object
7
8
9
|
# File 'lib/dhs/pagination/start.rb', line 7
def current_page
(offset + limit - 1) / limit
end
|
#next_offset(step = 1) ⇒ Object
11
12
13
|
# File 'lib/dhs/pagination/start.rb', line 11
def next_offset(step = 1)
self.class.next_offset(offset, limit, step)
end
|