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

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/kaminari/helpers/paginator.rb

Overview

Wraps a “page number” and provides some utility methods

Instance Method Summary collapse

Constructor Details

#initialize(options, page, last) ⇒ PageProxy

:nodoc:



78
79
80
# File 'lib/kaminari/helpers/paginator.rb', line 78

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

Instance Method Details

#+(other) ⇒ Object



140
141
142
# File 'lib/kaminari/helpers/paginator.rb', line 140

def +(other)
  to_i + other.to_i
end

#-(other) ⇒ Object



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

def -(other)
  to_i - other.to_i
end

#<=>(other) ⇒ Object



148
149
150
# File 'lib/kaminari/helpers/paginator.rb', line 148

def <=>(other)
  to_i <=> other.to_i
end

#current?Boolean

current page or not

Returns:

  • (Boolean)


88
89
90
# File 'lib/kaminari/helpers/paginator.rb', line 88

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

#first?Boolean

the first page or not

Returns:

  • (Boolean)


93
94
95
# File 'lib/kaminari/helpers/paginator.rb', line 93

def first?
  @page == 1
end

#inside_window?Boolean

inside the inner window or not

Returns:

  • (Boolean)


123
124
125
# File 'lib/kaminari/helpers/paginator.rb', line 123

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

#last?Boolean

the last page or not

Returns:

  • (Boolean)


98
99
100
# File 'lib/kaminari/helpers/paginator.rb', line 98

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

#left_outer?Boolean

within the left outer window or not

Returns:

  • (Boolean)


113
114
115
# File 'lib/kaminari/helpers/paginator.rb', line 113

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

#next?Boolean

the next page or not

Returns:

  • (Boolean)


108
109
110
# File 'lib/kaminari/helpers/paginator.rb', line 108

def next?
  @page == @options[:current_page] + 1
end

#numberObject

the page number



83
84
85
# File 'lib/kaminari/helpers/paginator.rb', line 83

def number
  @page
end

#prev?Boolean

the previous page or not

Returns:

  • (Boolean)


103
104
105
# File 'lib/kaminari/helpers/paginator.rb', line 103

def prev?
  @page == @options[:current_page] - 1
end

#right_outer?Boolean

within the right outer window or not

Returns:

  • (Boolean)


118
119
120
# File 'lib/kaminari/helpers/paginator.rb', line 118

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

#to_iObject



132
133
134
# File 'lib/kaminari/helpers/paginator.rb', line 132

def to_i
  number
end

#to_sObject



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

def to_s
  number.to_s
end

#was_truncated?Boolean

The last rendered tag was “truncated” or not

Returns:

  • (Boolean)


128
129
130
# File 'lib/kaminari/helpers/paginator.rb', line 128

def was_truncated?
  @last.is_a? Gap
end