Module: Gollum::Pagination::ClassMethods
- Defined in:
- lib/gollum-lib/pagination.rb
Instance Method Summary collapse
-
#log_pagination_options(options = {}) ⇒ Object
Fills in git-specific options for the log command using simple pagination options.
-
#page_to_skip(page, count = per_page) ⇒ Object
Turns a page number into an offset number for the git skip option.
Instance Method Details
#log_pagination_options(options = {}) ⇒ Object
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.
32 33 34 35 36 37 38 |
# File 'lib/gollum-lib/pagination.rb', line 32 def ( = {}) [:max_count] = .fetch(:per_page, per_page) .delete(:per_page) skip = page_to_skip(.delete(:page_num), [:max_count]) [:skip] = skip if skip > 0 end |
#page_to_skip(page, count = per_page) ⇒ Object
Turns a page number into an offset number for the git skip option.
page - Integer page number.
Returns an Integer.
19 20 21 |
# File 'lib/gollum-lib/pagination.rb', line 19 def page_to_skip(page, count = per_page) ([1, page.to_i].max - 1) * count end |