class Octokit::Connection::Paginator(T)

Overview

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>

Defined in:

octokit/connection.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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


[View source]

Instance Method Detail

def [](index) #

Get the record at a specific index.


[View source]
def []?(index) #

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


[View source]
def current_page : Int32 #

Get the current page.


[View source]
def empty? #

Checks if the paginator is empty.


[View source]
def fetch_all : Array(T) #

Fetch all pages.

Example:

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

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


[View source]
def fetch_next : Array(T) | Nil #

Fetch the next page.

Example:

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

[View source]
def fetch_page(page : Int32) : Array(T) | Nil #

Fetch a specific page.

Example:

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

[View source]
def fetch_previous : Array(T) | Nil #

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.


[View source]
def last? #

Checks if the current page is the last page.

Example:

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

[View source]
def last_response : Halite::Response | Nil #

[View source]
def next? : Bool #

Check if there is a next page.

Example:

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

[View source]
def previous? : Bool #

Check if there is a previous page.

Example:

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

[View source]
def records : Array(T) #

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


[View source]
def remaining : Int32 | Nil #

Get the number of pages remaining.

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


[View source]
def total_pages : Int32 | Nil #

Get the number of total pages for this query.

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


[View source]