Class: BootstrapPager::Helpers::Paginator::PageProxy

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/bootstrap_pager/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:


110
111
112
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 110

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

Instance Method Details

#+(other) ⇒ Object


172
173
174
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 172

def +(other)
  to_i + other.to_i
end

#-(other) ⇒ Object


176
177
178
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 176

def -(other)
  to_i - other.to_i
end

#<=>(other) ⇒ Object


180
181
182
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 180

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

#current?Boolean

current page or not

Returns:

  • (Boolean)

120
121
122
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 120

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

#first?Boolean

the first page or not

Returns:

  • (Boolean)

125
126
127
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 125

def first?
  @page == 1
end

#inside_window?Boolean

inside the inner window or not

Returns:

  • (Boolean)

155
156
157
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 155

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

#last?Boolean

the last page or not

Returns:

  • (Boolean)

130
131
132
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 130

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

#left_outer?Boolean

within the left outer window or not

Returns:

  • (Boolean)

145
146
147
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 145

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

#next?Boolean

the next page or not

Returns:

  • (Boolean)

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

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

#numberObject

the page number


115
116
117
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 115

def number
  @page
end

#prev?Boolean

the previous page or not

Returns:

  • (Boolean)

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

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

#right_outer?Boolean

within the right outer window or not

Returns:

  • (Boolean)

150
151
152
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 150

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

#to_iObject


164
165
166
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 164

def to_i
  number
end

#to_sObject


168
169
170
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 168

def to_s
  number.to_s
end

#was_truncated?Boolean

The last rendered tag was “truncated” or not

Returns:

  • (Boolean)

160
161
162
# File 'lib/bootstrap_pager/helpers/paginator.rb', line 160

def was_truncated?
  @last.is_a? Gap
end