class Kaminari::Helpers::Paginator::PageProxy

Wraps a “page number” and provides some utility methods

Public Instance Methods

current?() click to toggle source

current page or not

# File lib/kaminari/helpers/paginator.rb, line 100
def current?
  @page == @options[:current_page]
end
display_tag?() click to toggle source

Should we display the link tag?

# File lib/kaminari/helpers/paginator.rb, line 165
def display_tag?
  left_outer? || right_outer? || inside_window? || single_gap?
end
first?() click to toggle source

the first page or not

# File lib/kaminari/helpers/paginator.rb, line 105
def first?
  @page == 1
end
inside_window?() click to toggle source

inside the inner window or not

# File lib/kaminari/helpers/paginator.rb, line 144
def inside_window?
  (@options[:current_page] - @page).abs <= @options[:window]
end
last?() click to toggle source

the last page or not

# File lib/kaminari/helpers/paginator.rb, line 110
def last?
  @page == @options[:total_pages]
end
left_outer?() click to toggle source

within the left outer window or not

# File lib/kaminari/helpers/paginator.rb, line 134
def left_outer?
  @page <= @options[:left]
end
next?() click to toggle source

the next page or not

# File lib/kaminari/helpers/paginator.rb, line 120
def next?
  @page == @options[:current_page] + 1
end
number() click to toggle source

the page number

# File lib/kaminari/helpers/paginator.rb, line 95
def number
  @page
end
out_of_range?() click to toggle source

The page number exceeds the range of pages or not

# File lib/kaminari/helpers/paginator.rb, line 155
def out_of_range?
  @page > @options[:total_pages]
end
prev?() click to toggle source

the previous page or not

# File lib/kaminari/helpers/paginator.rb, line 115
def prev?
  @page == @options[:current_page] - 1
end
rel() click to toggle source

relationship with the current page

# File lib/kaminari/helpers/paginator.rb, line 125
def rel
  if next?
    'next'
  elsif prev?
    'prev'
  end
end
right_outer?() click to toggle source

within the right outer window or not

# File lib/kaminari/helpers/paginator.rb, line 139
def right_outer?
  @options[:total_pages] - @page < @options[:right]
end
single_gap?() click to toggle source

Current page is an isolated gap or not

# File lib/kaminari/helpers/paginator.rb, line 149
def single_gap?
  ((@page == @options[:current_page] - @options[:window] - 1) && (@page == @options[:left] + 1)) ||
    ((@page == @options[:current_page] + @options[:window] + 1) && (@page == @options[:total_pages] - @options[:right]))
end
was_truncated?() click to toggle source

The last rendered tag was “truncated” or not

# File lib/kaminari/helpers/paginator.rb, line 160
def was_truncated?
  @last.is_a? Gap
end