Skip to content
This repository

Added method Twitter::SearchResults#next_results? #366

Merged
merged 1 commit into from over 1 year ago

3 participants

Kenton White Erik Michaels-Ober Bruce Ackerman
Kenton White

Returns true if there is a next page for a Twitter SearchResult.
Returns false otherwise

Aliased to next_page? for backward compatibility with v1 API

Kenton White KentonWhite Added method Twitter::SearchResults#next_results?
Returns true if there is a next page for a Twitter SearchResult.
Returns false otherwise

Aliased to next_page? for backward compatibility with v1 API
d951db4
Erik Michaels-Ober
Owner

Looks good. Thanks for separating this out. :smile:

Erik Michaels-Ober sferik merged commit 7d9d6f9 into from
Erik Michaels-Ober sferik closed this
Bruce Ackerman

Ok, I'm confused do I do this to get to different pages of the results?

Twitter.search("#ruby", :next_results => "?")
Bruce Ackerman

And to see if there's a second page I would do. This is giving me a no method error.

Twitter.search("#ruby", :next_results => "?").next_results?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 13, 2013
Kenton White KentonWhite Added method Twitter::SearchResults#next_results?
Returns true if there is a next page for a Twitter SearchResult.
Returns false otherwise

Aliased to next_page? for backward compatibility with v1 API
d951db4
This page is out of date. Refresh to see the latest.
6 lib/twitter/search_results.rb
@@ -46,6 +46,12 @@ def search_metadata?
46 46 def since_id
47 47 @attrs[:search_metadata][:since_id] if search_metadata?
48 48 end
  49 +
  50 + # @return [Boolean]
  51 + def next_results?
  52 + !@attrs[:search_metadata][:next_results].nil? if search_metadata?
  53 + end
  54 + alias next_page? next_results?
49 55
50 56 end
51 57 end
15 spec/twitter/search_results_spec.rb
@@ -96,5 +96,20 @@
96 96 expect(since_id).to be_nil
97 97 end
98 98 end
  99 +
  100 + describe "#next_results?" do
  101 + it "returns true when next_results is set" do
  102 + next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?"}).next_results?
  103 + expect(next_results).to be_true
  104 + end
  105 + it "returns false when next_results is not set" do
  106 + next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
  107 + expect(next_results).to be_false
  108 + end
  109 + it "returns false is search_metadata is not set" do
  110 + next_results = Twitter::SearchResults.new().next_results?
  111 + expect(next_results).to be_false
  112 + end
  113 + end
99 114
100 115 end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.