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:



119
120
121
# File 'lib/kaminari/helpers/tags.rb', line 119

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

Instance Method Details

#current?Boolean

current page or not

Returns:

  • (Boolean)


129
130
131
# File 'lib/kaminari/helpers/tags.rb', line 129

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

#first?Boolean

the first page or not

Returns:

  • (Boolean)


134
135
136
# File 'lib/kaminari/helpers/tags.rb', line 134

def first?
  @page == 1
end

#inside_window?Boolean

inside the inner window or not

Returns:

  • (Boolean)


154
155
156
# File 'lib/kaminari/helpers/tags.rb', line 154

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

#last?Boolean

the last page or not

Returns:

  • (Boolean)


139
140
141
# File 'lib/kaminari/helpers/tags.rb', line 139

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

#left_outer?Boolean

within the left outer window or not

Returns:

  • (Boolean)


144
145
146
# File 'lib/kaminari/helpers/tags.rb', line 144

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

#numberObject

the page number



124
125
126
# File 'lib/kaminari/helpers/tags.rb', line 124

def number
  @page
end

#right_outer?Boolean

within the right outer window or not

Returns:

  • (Boolean)


149
150
151
# File 'lib/kaminari/helpers/tags.rb', line 149

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

#was_truncated?Boolean

The last rendered tag was “truncated” or not

Returns:

  • (Boolean)


159
160
161
# File 'lib/kaminari/helpers/tags.rb', line 159

def was_truncated?
  @last.is_a? TruncatedSpan
end