Class: RsPaginator::Collection

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rs_paginator/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(objects, page, per_page, total) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
11
12
13
# File 'lib/rs_paginator/collection.rb', line 7

def initialize(objects, page, per_page, total)
  @objects = objects
  @page = page.to_i
  @per_page = per_page.to_i
  @total = total.to_i
  super(objects)
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/rs_paginator/collection.rb', line 5

def page
  @page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



5
6
7
# File 'lib/rs_paginator/collection.rb', line 5

def per_page
  @per_page
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'lib/rs_paginator/collection.rb', line 5

def total
  @total
end

Instance Method Details

#total_pagesObject



15
16
17
# File 'lib/rs_paginator/collection.rb', line 15

def total_pages
  (@total.to_f / @per_page).ceil
end