Class: PaginateMe::PMView::PaginateMeBuilder
- Inherits:
-
Object
- Object
- PaginateMe::PMView::PaginateMeBuilder
- Includes:
- ActionView::Helpers
- Defined in:
- lib/paginate_me/paginate.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ PaginateMeBuilder
constructor
A new instance of PaginateMeBuilder.
- #link_to_first(options = {}) ⇒ Object
- #link_to_last(options = {}) ⇒ Object
- #link_to_next(options = {}) ⇒ Object
- #link_to_previous(options = {}) ⇒ Object
- #page_out_of_total(options = {}) ⇒ Object
Constructor Details
#initialize(options) ⇒ PaginateMeBuilder
Returns a new instance of PaginateMeBuilder.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/paginate_me/paginate.rb', line 62 def initialize() @slug = [:slug] ||= "page" @base_url = [:base_url] @per_page = [:per_page] @page_total = [:page_total] @current_page = [:current_page] @next_page = (@current_page >= @page_total ? @current_page : @current_page + 1).to_s @prev_page = (@current_page <= 1 ? @current_page : @current_page - 1).to_s end |
Instance Method Details
#link_to_first(options = {}) ⇒ Object
92 93 94 95 96 |
# File 'lib/paginate_me/paginate.rb', line 92 def link_to_first( = {}) [:name] ||= "First" add_to_template paginate_link_to 1, if @current_page > 1 end |
#link_to_last(options = {}) ⇒ Object
80 81 82 83 84 |
# File 'lib/paginate_me/paginate.rb', line 80 def link_to_last( = {}) [:name] ||= "Last" add_to_template paginate_link_to @page_total, if @current_page < @page_total end |
#link_to_next(options = {}) ⇒ Object
74 75 76 77 78 |
# File 'lib/paginate_me/paginate.rb', line 74 def link_to_next( = {}) [:name] ||= "Next" add_to_template paginate_link_to @next_page, if @current_page < @page_total end |
#link_to_previous(options = {}) ⇒ Object
86 87 88 89 90 |
# File 'lib/paginate_me/paginate.rb', line 86 def link_to_previous( = {}) [:name] ||= "Previous" add_to_template paginate_link_to @prev_page, if @current_page > 1 end |
#page_out_of_total(options = {}) ⇒ Object
98 99 100 101 |
# File 'lib/paginate_me/paginate.rb', line 98 def page_out_of_total( = {}) content = "#{@current_page} of #{@page_total}" add_to_template content_tag(:span,content, ) end |