From 0b37998055158d4fed0e3c296d8d2a42ac77d5d9 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 23 Sep 2010 17:13:56 -0700 Subject: [PATCH] Added a filter option to search, lets you specifiy options to filter by, such as 'links' (@pjdavis) --- lib/twitter/search.rb | 5 +++++ test/twitter/search_test.rb | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/twitter/search.rb b/lib/twitter/search.rb index 7549a78a2..4fee2a549 100644 --- a/lib/twitter/search.rb +++ b/lib/twitter/search.rb @@ -42,6 +42,11 @@ def containing(word, exclude=false) end alias :contains :containing + def filter(filter) + @query[:q] << "filter:#{filter}" + self + end + def retweeted @query[:q] << "rt" self diff --git a/test/twitter/search_test.rb b/test/twitter/search_test.rb index b7ed798b7..4718512dc 100644 --- a/test/twitter/search_test.rb +++ b/test/twitter/search_test.rb @@ -73,6 +73,10 @@ class SearchTest < Test::Unit::TestCase @search.not_retweeted.query[:q].should include('-rt') end + should "should be able to specify filters" do + @search.filter('links').query[:q].should include('filter:links') + end + should "should be able to specify hashed" do @search.hashed('twitter').query[:q].should include('#twitter') end