Skip to content

Commit

Permalink
Update Twitter::SearchResults class for Twitter API v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 18, 2012
1 parent e73cd76 commit f900358
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 15 deletions.
1 change: 0 additions & 1 deletion lib/twitter/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,6 @@ def retweeted_by_me(options={})
select_retweets(user_timeline(options.merge(count_options)))
end
end
alias retweeted_by retweeted_by_user

# Returns the 20 most recent retweets posted by users the authenticating user follow.
#
Expand Down
40 changes: 35 additions & 5 deletions lib/twitter/search_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,46 @@

module Twitter
class SearchResults < Twitter::Base
attr_reader :completed_in, :max_id, :next_page, :page, :query,
:refresh_url, :results_per_page, :since_id

# @return [Array<Twitter::Tweet>]
def results
@results ||= Array(@attrs[:results]).map do |tweet|
def statuses
@results ||= Array(@attrs[:statuses]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end
alias collection results
alias collection statuses
alias results statuses

# @return [Float]
def completed_in
@attrs[:search_metadata][:completed_in] unless @attrs[:search_metadata].nil?
end

# @return [Integer]
def max_id
@attrs[:search_metadata][:max_id] unless @attrs[:search_metadata].nil?
end

# @return [Integer]
def page
@attrs[:search_metadata][:page] unless @attrs[:search_metadata].nil?
end

# @return [String]
def query
@attrs[:search_metadata][:query] unless @attrs[:search_metadata].nil?
end

# @return [Integer]
def results_per_page
@attrs[:search_metadata][:results_per_page] unless @attrs[:search_metadata].nil?
end
alias rpp results_per_page

# @return [Integer]
def since_id
@attrs[:search_metadata][:since_id] unless @attrs[:search_metadata].nil?
end

end
end
Loading

0 comments on commit f900358

Please sign in to comment.