Module: Slingshot::Results::Pagination

Included in:
Collection
Defined in:
lib/slingshot/results/pagination.rb

Instance Method Summary collapse

Instance Method Details

#current_pageObject



15
16
17
# File 'lib/slingshot/results/pagination.rb', line 15

def current_page
  @options[:page].to_i
end

#next_pageObject



23
24
25
# File 'lib/slingshot/results/pagination.rb', line 23

def next_page
  @options[:page].to_i + 1
end

#previous_pageObject



19
20
21
# File 'lib/slingshot/results/pagination.rb', line 19

def previous_page
  @options[:page].to_i - 1
end

#total_entriesObject



6
7
8
# File 'lib/slingshot/results/pagination.rb', line 6

def total_entries
  @total
end

#total_pagesObject



10
11
12
13
# File 'lib/slingshot/results/pagination.rb', line 10

def total_pages
  result = @total.to_f / (@options[:per_page] ? @options[:per_page].to_i : 10 )
  result < 1 ? 1 : result.round
end