Parent

Files

Thoth::Pager

The Pager class provides a simple wrapper around a paginated Sequel dataset.

Public Class Methods

new(dataset, url) click to toggle source

Initializes a new Pager instance wrapping the given Sequel dataset and using url as the template for all generated URLs. url should be a string containing an sprintf flag (such as %s) in place of the page number.

# File lib/thoth/helper/pagination.rb, line 38
def initialize(dataset, url)
  @dataset = dataset
  @url     = url
end

Public Instance Methods

current_page() click to toggle source

Returns the number of the current page.

# File lib/thoth/helper/pagination.rb, line 44
def current_page
  @dataset.current_page
end
current_page_record_count() click to toggle source

Returns the number of records in the current page.

# File lib/thoth/helper/pagination.rb, line 49
def current_page_record_count
  @dataset.current_page_record_count
end
current_page_record_range() click to toggle source

Returns the record range for the current page.

# File lib/thoth/helper/pagination.rb, line 54
def current_page_record_range
  @dataset.current_page_record_range
end
next_page() click to toggle source

Returns the number of the next page or nil if the current page is the last.

# File lib/thoth/helper/pagination.rb, line 73
def next_page
  @dataset.next_page
end
next_url() click to toggle source

Returns the URL for the next page or nil if the current page is the last.

# File lib/thoth/helper/pagination.rb, line 79
def next_url
  next_page ? url(next_page) : nil
end
page_count() click to toggle source

Returns the total number of pages.

# File lib/thoth/helper/pagination.rb, line 84
def page_count
  @dataset.page_count
end
page_range() click to toggle source

Returns the page range.

# File lib/thoth/helper/pagination.rb, line 89
def page_range
  @dataset.page_range
end
page_size() click to toggle source

Returns the number of records per page.

# File lib/thoth/helper/pagination.rb, line 94
def page_size
  @dataset.page_size
end
prev_page() click to toggle source

Returns the number of the previous page or nil if the current page is the first.

# File lib/thoth/helper/pagination.rb, line 100
def prev_page
  @dataset.prev_page
end
prev_url() click to toggle source

Returns the URL for the previous page or nil if the current page is the first.

# File lib/thoth/helper/pagination.rb, line 106
def prev_url
  prev_page ? url(prev_page) : nil
end
record_count() click to toggle source

Returns the total number of records in the dataset.

# File lib/thoth/helper/pagination.rb, line 111
def record_count
  @dataset.pagination_record_count
end
url(page) click to toggle source

Returns the URL for the specified page number.

# File lib/thoth/helper/pagination.rb, line 116
def url(page)
  sprintf(@url, page.to_i)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.