sferik/twitter — pull request #365 by KentonWhite (2013-03-13 20:50:36+00:00)
Title: Add Twitter::SearchResults methods for handling next results

Twitter API v1.1 pages the search results. The information for the next page of search results is contained in the search_metadata field as a query string for the URL. This makes it difficult to use with the Twitter gem, which stores the query parameters as an options hash.

Added 2 methods to Twitter::SearchResults: next_results? and next_results

next_results? returns true if next_results if defined, false otherwise

next_results returns a hash of query parameters that can be merged into the original search options hash. Using the new hash then returns the next page of results.

Example usage:

search_results = twitter.search(query, opts)
while search_results.next_page?
opts.merge! search_results.next_page
search_results = twitter.search(query, opts)
end

For backwards compatibility with v1 API, aliased next_results? to next_page? and next_results to next_page