Class: Thoth::Pager

### Home Classes Methods

### In Files

- lib/thoth/helper/pagination.rb

### Parent

Object

### Methods

- ::new
- #current_page
- #current_page_record_count
- #current_page_record_range
- #navigate
- #navigation?
- #next_page
- #next_url
- #page_count
- #page_range
- #page_size
- #prev_page
- #prev_url
- #record_count
- #url

### Files

- robots.txt

### Class/Module Index

Quicksearch

- Thoth
- Thoth::AdminController
- Thoth::ArchiveController
- Thoth::Comment
- Thoth::CommentApiController
- Thoth::CommentController
- Thoth::Config
- Thoth::Error
- Thoth::Importer
- Thoth::MainController
- Thoth::Media
- Thoth::MediaController
- Thoth::MinifyController
- Thoth::Page
- Thoth::PageApiController
- Thoth::PageController
- Thoth::Pager
- Thoth::Plugin
- Thoth::Plugin::Delicious
- Thoth::Plugin::Flickr
- Thoth::Plugin::Tags
- Thoth::Plugin::Twitter
- Thoth::Post
- Thoth::PostApiController
- Thoth::PostController
- Thoth::SchemaError
- Thoth::SearchController
- Thoth::Tag
- Thoth::TagApiController
- Thoth::TagController
- Thoth::TagsPostsMap
- Ramaze
- Ramaze::Dispatcher
- Ramaze::Dispatcher::File
- Ramaze::Helper
- Ramaze::Helper::Admin
- Ramaze::Helper::Cookie
- Ramaze::Helper::Error
- Ramaze::Helper::Pagination
- Ramaze::Helper::Sanitize
- Ramaze::Helper::Wiki
- Ramaze::Helper::Ysearch
- Ramaze::Helper::Ysearch::SearchError
- AddMediaSize
- CreateSchema
- PantsImporter
- PoseidonImporter

No matching classes.

# 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

navigate() click to toggle source

Iterates over all pages within 5 steps from the current page, yielding the page number and URL for each.

    # File lib/thoth/helper/pagination.rb, line 60
    def navigate # :yields: page, url
      nav_start = [current_page - 5, 1].max
      nav_end   = [nav_start + 9, page_count].min
      (nav_start..nav_end).each {|page| yield page, url(page) }
    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.