Class: SourceMonitor::Pagination::Result
- Inherits:
-
Struct
- Object
- Struct
- SourceMonitor::Pagination::Result
- Defined in:
- lib/source_monitor/pagination/paginator.rb
Instance Attribute Summary collapse
-
#has_next_page ⇒ Object
Returns the value of attribute has_next_page.
-
#has_previous_page ⇒ Object
Returns the value of attribute has_previous_page.
-
#page ⇒ Object
Returns the value of attribute page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#records ⇒ Object
Returns the value of attribute records.
-
#total_count ⇒ Object
Returns the value of attribute total_count.
Instance Method Summary collapse
- #has_next_page? ⇒ Boolean
- #has_previous_page? ⇒ Boolean
- #next_page ⇒ Object
- #previous_page ⇒ Object
- #total_pages ⇒ Object
Instance Attribute Details
#has_next_page ⇒ Object
Returns the value of attribute has_next_page
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def has_next_page @has_next_page end |
#has_previous_page ⇒ Object
Returns the value of attribute has_previous_page
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def has_previous_page @has_previous_page end |
#page ⇒ Object
Returns the value of attribute page
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def page @page end |
#per_page ⇒ Object
Returns the value of attribute per_page
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def per_page @per_page end |
#records ⇒ Object
Returns the value of attribute records
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def records @records end |
#total_count ⇒ Object
Returns the value of attribute total_count
5 6 7 |
# File 'lib/source_monitor/pagination/paginator.rb', line 5 def total_count @total_count end |
Instance Method Details
#has_next_page? ⇒ Boolean
14 15 16 |
# File 'lib/source_monitor/pagination/paginator.rb', line 14 def has_next_page? !!has_next_page end |
#has_previous_page? ⇒ Boolean
18 19 20 |
# File 'lib/source_monitor/pagination/paginator.rb', line 18 def has_previous_page? !!has_previous_page end |
#next_page ⇒ Object
22 23 24 25 26 |
# File 'lib/source_monitor/pagination/paginator.rb', line 22 def next_page return nil unless has_next_page page + 1 end |
#previous_page ⇒ Object
28 29 30 31 32 |
# File 'lib/source_monitor/pagination/paginator.rb', line 28 def previous_page return nil unless has_previous_page [ page - 1, 1 ].max end |
#total_pages ⇒ Object
34 35 36 37 38 |
# File 'lib/source_monitor/pagination/paginator.rb', line 34 def total_pages return 1 if total_count.nil? || total_count <= 0 [ 1, (total_count.to_f / per_page).ceil ].max end |