Permalink
Browse files

Added page to search. Also added spec for it and added it to an example.

  • Loading branch information...
1 parent 40d2f1a commit 977023126fbe7fdf13af53d840ca3b6807cd2d85 @jnunemaker jnunemaker committed Jan 5, 2009
Showing with 11 additions and 0 deletions.
  1. +1 −0 examples/search.rb
  2. +6 −0 lib/twitter/search.rb
  3. +4 −0 spec/search_spec.rb
View
@@ -2,6 +2,7 @@
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
Twitter::Search.new('httparty').each { |r| puts r.inspect,'' }
+Twitter::Search.new('httparty').page(2).each { |r| puts r.inspect, '' }
# search = Twitter::Search.new
# search.from('jnunemaker').to('oaknd1').each { |r| puts r.inspect, '' }
View
@@ -59,6 +59,12 @@ def per_page(num)
self
end
+ # Which page of results to fetch
+ def page(num)
+ @query[:page] = num
+ self
+ end
+
# Only searches tweets since a given id.
# Recommended to use this when possible.
def since(since_id)
View
@@ -49,6 +49,10 @@
@search.per_page(25).query[:rpp].should == 25
end
+ it "should be able to specify the page number" do
+ @search.page(20).query[:page].should == 20
+ end
+
it "should be able to specify only returning results greater than an id" do
@search.since(1234).query[:since_id].should == 1234
end

0 comments on commit 9770231

Please sign in to comment.