class PostgresqlWeb::Paginator
Attributes
data[R]
page[R]
per_page[R]
total_records[R]
Public Class Methods
new(data, page, per_page, total_records)
click to toggle source
# File lib/postgresql_web/paginator.rb, line 5 def initialize(data, page, per_page, total_records) @data = data @page = page.to_i @per_page = per_page.to_i @total_records = total_records.to_i end
Public Instance Methods
first_page?()
click to toggle source
# File lib/postgresql_web/paginator.rb, line 28 def first_page? page.to_i <= 1 end
last_page?()
click to toggle source
# File lib/postgresql_web/paginator.rb, line 31 def last_page? page == total_pages end
offset()
click to toggle source
# File lib/postgresql_web/paginator.rb, line 12 def offset if page > 0 self.per_page * ( page - 1) else 0 end end
total_pages()
click to toggle source
# File lib/postgresql_web/paginator.rb, line 20 def total_pages if self.total_records > 0 (self.total_records.to_f / self.per_page).ceil else 1 end end