Class: PaginateMe::PMView::PaginateMeBuilder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers
Defined in:
lib/paginate_me/paginate.rb

Instance Method Summary collapse

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(options)

  @slug = options[:slug] ||= "page"
  @base_url = options[:base_url]
  @per_page = options[:per_page]
  @page_total = options[:page_total]
  @current_page = options[: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



92
93
94
95
96
# File 'lib/paginate_me/paginate.rb', line 92

def link_to_first(options = {})
  options[:name] ||= "First"

  add_to_template paginate_link_to 1, options if @current_page > 1
end


80
81
82
83
84
# File 'lib/paginate_me/paginate.rb', line 80

def link_to_last(options = {})
  options[:name] ||= "Last"
  
  add_to_template paginate_link_to @page_total, options if @current_page < @page_total 
end


74
75
76
77
78
# File 'lib/paginate_me/paginate.rb', line 74

def link_to_next(options = {})
  options[:name] ||= "Next"

  add_to_template paginate_link_to @next_page, options if @current_page < @page_total
end


86
87
88
89
90
# File 'lib/paginate_me/paginate.rb', line 86

def link_to_previous(options = {})
  options[:name] ||= "Previous"

  add_to_template paginate_link_to @prev_page, options 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(options = {})
  content = "#{@current_page} of #{@page_total}"
  add_to_template (:span,content, options)
end