class PolicyManager::BootstrapLinkRenderer
Constants
- ELLIPSIS
Public Instance Methods
container_attributes()
click to toggle source
Calls superclass method
# File lib/policy_manager/bootstrap_link_renderer.rb, line 25 def container_attributes super.except(*[:link_options]) end
to_html()
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 11 def to_html list_items = pagination.map do |item| case item when (1.class == Integer ? Integer : Fixnum) page_number(item) else send(item) end end.join("") list_wrapper = tag :nav, list_items, class: "pagination button-group" tag :nav, list_wrapper end
Protected Instance Methods
gap()
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 54 def gap tag :li, tag(:i, ELLIPSIS, class: 'page-link'), class: 'page-item disabled' end
next_page()
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 63 def next_page num = @collection.current_page < @collection.total_pages && @collection.current_page + 1 previous_or_next_page num, @options[:next_label], 'next' end
page_number(page)
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 31 def page_number(page) link_options = @options[:link_options] || {} if page == current_page tag :li, tag(:span, page, class: 'page-link'), class: 'page-item active' else link_options.merge! class: 'page-link', rel: rel_value(page) tag :li, link(page, page, link_options), class: 'page-item' end end
previous_or_next_page(page, text, classname)
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 42 def previous_or_next_page(page, text, classname) link_options = @options[:link_options] || {} if page link_wrapper = link(text, page, link_options.merge(class: 'page-link')) tag :li, link_wrapper, class: 'page-item' else span_wrapper = tag(:span, text, class: 'page-link') tag :li, span_wrapper, class: 'page-item disabled' end end
previous_page()
click to toggle source
# File lib/policy_manager/bootstrap_link_renderer.rb, line 58 def previous_page num = @collection.current_page > 1 && @collection.current_page - 1 previous_or_next_page num, @options[:previous_label], 'previous' end