class

Octokit::Connection::Paginator(T)

Inherits Reference < Object

Returned for all paginated responses, such as with Client::Repositories#repositories. Allows you to fetch the next page, the last page, or fetch all pages in a response.

Examples:

pages = @client.repositories
pp pages
# => #<Octokit::Connection::Paginator(Octokit::Models::Repository):0x555c3d36a000>

Constructors

new(client : Octokit::Client, url : String, current_page : Int32 | Nil = nil, per_page : Int32 | Nil = nil, auto_paginate : Bool | Nil = nil, options : Halite::Options | Nil = nil)

Create a new instance of Connection::Paginator

Source

Instance methods

[](index)

Get the record at a specific index.

Source
[]?(index)

Get the record at a specific index, returning nil if the index contains no record.

Source
current_page

Get the current page.

Source
empty?

Checks if the paginator is empty.

Source
fetch_all

Fetch all pages.

Example:

@client.repositories.fetch_all # => Array(Repository)

Note: This is automatically called if Configurable#auto_paginate is set to true.

Source
fetch_next

Fetch the next page.

Example:

pages = @client.repositories
pages.fetch_next # => Array(Repository)
Source
fetch_page(page : Int32) : Array(T) | Nil

Fetch a specific page.

Example:

pages = @client.repositories
pages.fetch_page(4) # => Array(Repository)
Source
fetch_previous

Fetch the previous page.

Example:

pages = @client.repositories
pages.fetch_next
pages.fetch_previous # => Array(Repository)

Note: This is really only useful if you want to fetch records backwards for some reason. Included just in case.

Source
last?

Checks if the current page is the last page.

Example:

pages = @client.repositories
pages.fetch_all
pages.last? # => Bool
Source
last_response
Source
next?

Check if there is a next page.

Example:

pages = @client.repositories
pages.fetch_next
pages.next? # => Bool
Source
previous?

Check if there is a previous page.

Example:

pages = @client.repositories
pages.fetch_next
pages.previous? # => Bool
Source
records

Get all collected records. This is updated every time a fetch_* method is called.

Source
remaining

Get the number of pages remaining.

Note: This is only not nil after a page has been fetched.

Source
total_pages

Get the number of total pages for this query.

Note: This is only not nil after a page has been fetched.

Source