Class: Hanami::Pagination::MockPager
- Inherits:
-
Object
- Object
- Hanami::Pagination::MockPager
- Defined in:
- lib/hanami/pagination/mock_pager.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
readonly
Returns the value of attribute current_page.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
- #first_page? ⇒ Boolean
-
#initialize(current_page, total_pages) ⇒ MockPager
constructor
A new instance of MockPager.
- #last_page? ⇒ Boolean
- #next_page ⇒ Object
- #prev_page ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(current_page, total_pages) ⇒ MockPager
Returns a new instance of MockPager.
6 7 8 9 |
# File 'lib/hanami/pagination/mock_pager.rb', line 6 def initialize(current_page, total_pages) @current_page = current_page @total_pages = total_pages end |
Instance Attribute Details
#current_page ⇒ Object (readonly)
Returns the value of attribute current_page.
4 5 6 |
# File 'lib/hanami/pagination/mock_pager.rb', line 4 def current_page @current_page end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
4 5 6 |
# File 'lib/hanami/pagination/mock_pager.rb', line 4 def total_pages @total_pages end |
Instance Method Details
#first_page? ⇒ Boolean
27 28 29 |
# File 'lib/hanami/pagination/mock_pager.rb', line 27 def first_page? current_page == 1 end |
#last_page? ⇒ Boolean
31 32 33 |
# File 'lib/hanami/pagination/mock_pager.rb', line 31 def last_page? current_page == total_pages end |
#next_page ⇒ Object
11 12 13 |
# File 'lib/hanami/pagination/mock_pager.rb', line 11 def next_page [current_page + 1, total_pages].min end |
#prev_page ⇒ Object
15 16 17 |
# File 'lib/hanami/pagination/mock_pager.rb', line 15 def prev_page [current_page - 1, 1].max end |
#total ⇒ Object
19 20 21 |
# File 'lib/hanami/pagination/mock_pager.rb', line 19 def total total_pages end |