Skip to content

Commit

Permalink
Added page to search. Also added spec for it and added it to an example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Jan 5, 2009
1 parent 40d2f1a commit 9770231
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, '' }
Expand Down
6 changes: 6 additions & 0 deletions lib/twitter/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions spec/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9770231

Please sign in to comment.