class Octokit::Connection::Paginator(T)
- Octokit::Connection::Paginator(T)
- Reference
- Object
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.crConstructors
-
.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
Instance Method Summary
-
#[](index)
Get the record at a specific index.
-
#[]?(index)
Get the record at a specific index, returning
nil
if the index contains no record. -
#current_page : Int32
Get the current page.
-
#empty? : Bool
Checks if the paginator is empty.
-
#fetch_all : Array(T)
Fetch all pages.
-
#fetch_next : Array(T) | Nil
Fetch the next page.
-
#fetch_page(page : Int32) : Array(T) | Nil
Fetch a specific page.
-
#fetch_previous : Array(T) | Nil
Fetch the previous page.
-
#last? : Bool
Checks if the current page is the last page.
- #last_response : Halite::Response | Nil
-
#next? : Bool
Check if there is a next page.
-
#previous? : Bool
Check if there is a previous page.
-
#records : Array(T)
Get all collected records.
-
#remaining : Int32 | Nil
Get the number of pages remaining.
-
#total_pages : Int32 | Nil
Get the number of total pages for this query.
Constructor Detail
Create a new instance of Connection::Paginator
Instance Method Detail
Fetch all pages.
Example:
@client.repositories.fetch_all # => Array(Repository)
Note: This is automatically called if Configurable#auto_paginate
is set to true.
Fetch the next page.
Example:
pages = @client.repositories
pages.fetch_next # => Array(Repository)
Fetch a specific page.
Example:
pages = @client.repositories
pages.fetch_page(4) # => Array(Repository)
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.
Checks if the current page is the last page.
Example:
pages = @client.repositories
pages.fetch_all
pages.last? # => Bool
Check if there is a next page.
Example:
pages = @client.repositories
pages.fetch_next
pages.next? # => Bool
Check if there is a previous page.
Example:
pages = @client.repositories
pages.fetch_next
pages.previous? # => Bool
Get all collected records. This is updated every time
a fetch_*
method is called.
Get the number of pages remaining.
Note: This is only not nil after a page has been fetched.
Get the number of total pages for this query.
Note: This is only not nil after a page has been fetched.