will_paginate

https://github.com/mislav/will_paginate

Ruby

Pagination library for Rails and other Ruby applications

Array#paginate

Paginates a static array (extracting a subset of it). The result is a
WillPaginate::Collection instance, which is an array with a few more
properties about its paginated state.

Parameters:
* <tt>:page</tt> - current page, defaults to 1
* <tt>:per_page</tt> - limit of items per page, defaults to 30
* <tt>:total_entries</tt> - total number of items in the array, defaults to
  <tt>array.length</tt> (obviously)

Example:
  arr = ['a', 'b', 'c', 'd', 'e']
  paged = arr.paginate(:per_page => 2)      #->  ['a', 'b']
  paged.total_entries                       #->  5
  arr.paginate(:page => 2, :per_page => 2)  #->  ['c', 'd']
  arr.paginate(:page => 3, :per_page => 2)  #->  ['e']

This method was originally {suggested by Desi
McAdam}[http://www.desimcadam.com/archives/8] and later proved to be the
most useful method of will_paginate library.

Source | Google | Stack overflow

Edit

git clone [email protected]:mislav/will_paginate.git

cd will_paginate

open lib/will_paginate/array.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Array-paginate-for-pr


# Commit to git

git add lib/will_paginate/array.rbgit commit -m "better docs for Array#paginate"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Array-paginate-for-pr

hub pull-request


# Celebrate!