module Gollum::Pagination::ClassMethods

Public Instance Methods

log_pagination_options(options = {}) click to toggle source

Fills in git-specific options for the log command using simple pagination options.

options - Hash of options:

:page_num - Optional Integer page number (default: 1)
:per_page - Optional Integer max count of items to return.
           Defaults to #per_class class method.

Returns Hash with :max_count and :skip keys.

# File lib/gollum-lib/pagination.rb, line 32
def log_pagination_options(options = {})
  options[:max_count] = options.fetch(:per_page, per_page)
  options.delete(:per_page)
  skip                = page_to_skip(options.delete(:page_num), options[:max_count])
  options[:skip]      = skip if skip > 0
  options
end
page_to_skip(page, count = per_page) click to toggle source

Turns a page number into an offset number for the git skip option.

page - Integer page number.

Returns an Integer.

# File lib/gollum-lib/pagination.rb, line 19
def page_to_skip(page, count = per_page)
  ([1, page.to_i].max - 1) * count
end