Class: PaginationHelper::Paginator::Window

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/pagination_helper.rb

Overview

A class for representing ranges around a given page.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, padding = 2) ⇒ Window

Creates a new Window object for the given page with the specified padding.



454
455
456
457
458
# File 'app/helpers/pagination_helper.rb', line 454

def initialize(page, padding=2)
  @paginator = page.paginator
  @page = page
  self.padding = padding
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



471
472
473
# File 'app/helpers/pagination_helper.rb', line 471

def first
  @first
end

#lastObject (readonly)

Returns the value of attribute last.



471
472
473
# File 'app/helpers/pagination_helper.rb', line 471

def last
  @last
end

#paddingObject

Returns the value of attribute padding.



471
472
473
# File 'app/helpers/pagination_helper.rb', line 471

def padding
  @padding
end

#pageObject (readonly)

Returns the value of attribute page.



459
460
461
# File 'app/helpers/pagination_helper.rb', line 459

def page
  @page
end

#paginatorObject (readonly)

Returns the value of attribute paginator.



459
460
461
# File 'app/helpers/pagination_helper.rb', line 459

def paginator
  @paginator
end

Instance Method Details

#pagesObject Also known as: to_a

Returns an array of Page objects in the current window.



474
475
476
# File 'app/helpers/pagination_helper.rb', line 474

def pages
  (@first.number..@last.number).to_a.map {|n| @paginator[n]}
end