Class: Kaminari::Helpers::Paginator::PageProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/kaminari/helpers/tags.rb

Overview

Wraps a “page number” and provides some utility methods

Instance Method Summary collapse

Constructor Details

#initialize(options, page, last) ⇒ PageProxy

:nodoc:



116
117
118
# File 'lib/kaminari/helpers/tags.rb', line 116

def initialize(options, page, last) #:nodoc:
  @options, @page, @last = options, page, last
end

Instance Method Details

#current?Boolean

current page or not

Returns:

  • (Boolean)


126
127
128
# File 'lib/kaminari/helpers/tags.rb', line 126

def current?
  @page == @options[:current_page]
end

#first?Boolean

the first page or not

Returns:

  • (Boolean)


131
132
133
# File 'lib/kaminari/helpers/tags.rb', line 131

def first?
  @page == 1
end

#inside_window?Boolean

inside the inner window or not

Returns:

  • (Boolean)


151
152
153
# File 'lib/kaminari/helpers/tags.rb', line 151

def inside_window?
  (@page - @options[:current_page]).abs <= @options[:window]
end

#last?Boolean

the last page or not

Returns:

  • (Boolean)


136
137
138
# File 'lib/kaminari/helpers/tags.rb', line 136

def last?
  @page == @options[:num_pages]
end

#left_outer?Boolean

within the left outer window or not

Returns:

  • (Boolean)


141
142
143
# File 'lib/kaminari/helpers/tags.rb', line 141

def left_outer?
  @page <= @options[:left] + 1
end

#numberObject

the page number



121
122
123
# File 'lib/kaminari/helpers/tags.rb', line 121

def number
  @page
end

#right_outer?Boolean

within the right outer window or not

Returns:

  • (Boolean)


146
147
148
# File 'lib/kaminari/helpers/tags.rb', line 146

def right_outer?
  @options[:num_pages] - @page <= @options[:right]
end

#was_truncated?Boolean

The last rendered tag was “truncated” or not

Returns:

  • (Boolean)


156
157
158
# File 'lib/kaminari/helpers/tags.rb', line 156

def was_truncated?
  @last.is_a? TruncatedSpan
end