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:



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

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

Instance Method Details

#+(other) ⇒ Object



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

def +(other)
  to_i + other.to_i
end

#-(other) ⇒ Object



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

def -(other)
  to_i - other.to_i
end

#<=>(other) ⇒ Object



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

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

#current?Boolean

current page or not

Returns:

  • (Boolean)


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

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

#first?Boolean

the first page or not

Returns:

  • (Boolean)


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

def first?
  @page == 1
end

#inside_window?Boolean

inside the inner window or not

Returns:

  • (Boolean)


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

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

#last?Boolean

the last page or not

Returns:

  • (Boolean)


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

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

#left_outer?Boolean

within the left outer window or not

Returns:

  • (Boolean)


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

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

#next?Boolean

the next page or not

Returns:

  • (Boolean)


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

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

#numberObject

the page number



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

def number
  @page
end

#prev?Boolean

the previous page or not

Returns:

  • (Boolean)


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

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

#right_outer?Boolean

within the right outer window or not

Returns:

  • (Boolean)


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

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

#to_iObject



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

def to_i
  number
end

#to_sObject



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

def to_s
  number.to_s
end

#was_truncated?Boolean

The last rendered tag was “truncated” or not

Returns:

  • (Boolean)


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

def was_truncated?
  @last.is_a? Gap
end