Module: OklahomaMixer::TableDatabase::Paginated

Defined in:
lib/oklahoma_mixer/table_database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageObject

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_pageObject

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_entriesObject

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_pageObject


29
30
31
# File 'lib/oklahoma_mixer/table_database.rb', line 29

def next_page
  current_page < total_pages ? (current_page + 1) : nil
end

#offsetObject


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_pageObject


25
26
27
# File 'lib/oklahoma_mixer/table_database.rb', line 25

def previous_page
  current_page > 1 ? (current_page - 1) : nil
end

#total_pagesObject


13
14
15
# File 'lib/oklahoma_mixer/table_database.rb', line 13

def total_pages
  (total_entries / per_page.to_f).ceil
end