Class: Hockey::PagingArray

Inherits:
Array
  • Object
show all
Defined in:
lib/hockeyhelper/paging_array.rb

Direct Known Subclasses

OrderedPagingArray

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePagingArray


9
10
11
12
# File 'lib/hockeyhelper/paging_array.rb', line 9

def initialize
  super
  @per_page = 25
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page


4
5
6
# File 'lib/hockeyhelper/paging_array.rb', line 4

def current_page
  @current_page
end

#per_pageObject (readonly)

25


5
6
7
# File 'lib/hockeyhelper/paging_array.rb', line 5

def per_page
  @per_page
end

#total_entriesObject (readonly)

Returns the value of attribute total_entries


6
7
8
# File 'lib/hockeyhelper/paging_array.rb', line 6

def total_entries
  @total_entries
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages


7
8
9
# File 'lib/hockeyhelper/paging_array.rb', line 7

def total_pages
  @total_pages
end

Instance Method Details

#update_page(hashobj) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/hockeyhelper/paging_array.rb', line 14

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) ⇒ Object


22
23
24
25
26
27
28
# File 'lib/hockeyhelper/paging_array.rb', line 22

def update_page_with(page, size)
  @current_page = page
  @total_entries = size
  @total_pages = (size / @per_page) + 1

  self
end