class Hockey::PagingArray
Attributes
current_page[R]
per_page[R]
total_entries[R]
total_pages[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/hockeyhelper/paging_array.rb, line 20 def initialize super @per_page = 25 end
paginate(with: [], page: 1)
click to toggle source
# File lib/hockeyhelper/paging_array.rb, line 11 def self.paginate(with: [], page: 1) obj = self.new obj.replace(with[(page - 1) * obj.per_page, obj.per_page]) obj.update_page_with(page, with.size) obj rescue raise PageRangeError, 'your specified page is out of range in array' end
Public Instance Methods
update_page(hashobj)
click to toggle source
# File lib/hockeyhelper/paging_array.rb, line 25 def update_page(hashobj) @current_page = hashobj['current_page'].to_i @total_entries = hashobj['total_entries'].to_i @total_pages = hashobj['total_pages'].to_i self end
update_page_with(page, size)
click to toggle source
# File lib/hockeyhelper/paging_array.rb, line 33 def update_page_with(page, size) @current_page = page @total_entries = size @total_pages = (size / @per_page) + 1 self end