Module: OklahomaMixer::TableDatabase::Paginated
- Defined in:
- lib/oklahoma_mixer/table_database.rb
Instance Attribute Summary collapse
-
#current_page ⇒ Object
Returns the value of attribute current_page.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#total_entries ⇒ Object
Returns the value of attribute total_entries.
Instance Method Summary collapse
- #next_page ⇒ Object
- #offset ⇒ Object
- #out_of_bounds? ⇒ Boolean
- #previous_page ⇒ Object
- #total_pages ⇒ Object
Instance Attribute Details
#current_page ⇒ Object
Returns the value of attribute current_page.
11 12 13 |
# File 'lib/oklahoma_mixer/table_database.rb', line 11 def current_page @current_page end |
#per_page ⇒ Object
Returns the value of attribute per_page.
11 12 13 |
# File 'lib/oklahoma_mixer/table_database.rb', line 11 def per_page @per_page end |
#total_entries ⇒ Object
Returns the value of attribute total_entries.
11 12 13 |
# File 'lib/oklahoma_mixer/table_database.rb', line 11 def total_entries @total_entries end |
Instance Method Details
#next_page ⇒ Object
29 30 31 |
# File 'lib/oklahoma_mixer/table_database.rb', line 29 def next_page current_page < total_pages ? (current_page + 1) : nil end |
#offset ⇒ Object
21 22 23 |
# File 'lib/oklahoma_mixer/table_database.rb', line 21 def offset (current_page - 1) * per_page end |
#out_of_bounds? ⇒ Boolean
17 18 19 |
# File 'lib/oklahoma_mixer/table_database.rb', line 17 def out_of_bounds? current_page > total_pages end |
#previous_page ⇒ Object
25 26 27 |
# File 'lib/oklahoma_mixer/table_database.rb', line 25 def previous_page current_page > 1 ? (current_page - 1) : nil end |
#total_pages ⇒ Object
13 14 15 |
# File 'lib/oklahoma_mixer/table_database.rb', line 13 def total_pages (total_entries / per_page.to_f).ceil end |