Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Twitter::SearchResults#refresh_url

  • Loading branch information...
commit 6bf08c008de139aad3ec173461e8633bfa5a3bd8 1 parent 54bdde1
@mustafaturan mustafaturan authored
Showing with 26 additions and 0 deletions.
  1. +11 −0 lib/twitter/search_results.rb
  2. +15 −0 spec/twitter/search_results_spec.rb
View
11 lib/twitter/search_results.rb
@@ -63,5 +63,16 @@ def next_results
Faraday::Utils.parse_nested_query(@attrs[:search_metadata][:next_results][1..-1]).inject({}) { |memo, (k,v)| memo[k.to_sym] = v; memo} if next_results?
end
alias next_page next_results
+
+ # Returns a Hash of query parameters for the refresh url in the search
+ #
+ # Returned Hash can be merged into the previous search options list
+ # to easily access the refresh page
+ #
+ # @return [Hash]
+ def refresh_url
+ Faraday::Utils.parse_nested_query(@attrs[:search_metadata][:refresh_url][1..-1]).inject({}) { |memo, (k,v)| memo[k.to_sym] = v; memo}
+ end
+ alias refresh_page refresh_url
end
end
View
15 spec/twitter/search_results_spec.rb
@@ -127,4 +127,19 @@
end
end
+ describe "#refresh_url" do
+ let(:refresh_url) {Twitter::SearchResults.new(:search_metadata =>
+ {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"
+ }).refresh_url
+ }
+
+ it "returns a hash of query parameters" do
+ expect(refresh_url).to be_a Hash
+ end
+
+ it "returns a since_id" do
+ expect(refresh_url[:since_id]).to eq "249279667666817023"
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.