Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit d951db4bdaa1ef72383f2026ec6236a289ee9074 1 parent 68915e0
@KentonWhite KentonWhite authored
View
6 lib/twitter/search_results.rb
@@ -46,6 +46,12 @@ def search_metadata?
def since_id
@attrs[:search_metadata][:since_id] if search_metadata?
end
+
+ # @return [Boolean]
+ def next_results?
+ !@attrs[:search_metadata][:next_results].nil? if search_metadata?
+ end
+ alias next_page? next_results?
end
end
View
15 spec/twitter/search_results_spec.rb
@@ -96,5 +96,20 @@
expect(since_id).to be_nil
end
end
+
+ describe "#next_results?" do
+ it "returns true when next_results is set" do
+ next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?"}).next_results?
+ expect(next_results).to be_true
+ end
+ it "returns false when next_results is not set" do
+ next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
+ expect(next_results).to be_false
+ end
+ it "returns false is search_metadata is not set" do
+ next_results = Twitter::SearchResults.new().next_results?
+ expect(next_results).to be_false
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.