Class: Her::PaginatedCollection

Inherits:
Collection
  • Object
show all
Defined in:
lib/her/paginated_collection.rb

Instance Attribute Summary

Attributes inherited from Collection

#errors, #metadata

Instance Method Summary collapse

Methods inherited from Collection

#initialize

Constructor Details

This class inherits a constructor from Her::Collection

Instance Method Details

#current_pageObject



3
4
5
# File 'lib/her/paginated_collection.rb', line 3

def current_page
  [:current_page].to_i
end

#per_pageObject



7
8
9
# File 'lib/her/paginated_collection.rb', line 7

def per_page
  [:per_page].to_i
end

#total_entriesObject



11
12
13
# File 'lib/her/paginated_collection.rb', line 11

def total_entries
  [:total_entries].to_i
end

#total_pagesObject



15
16
17
18
# File 'lib/her/paginated_collection.rb', line 15

def total_pages
  return 0 if total_entries == 0 || per_page == 0
  (total_entries.to_f / per_page).ceil
end