Class: Wuclan::Twitter::Scrape::TwitterFavoritesRequest
- Defined in:
- lib/wuclan/twitter/scrape/twitter_followers_request.rb
Overview
API request for the tweets favorited by the given user. At 20 requests per page, this is the worst bargain on the Twitter API call market.
Produces max 20 TwitterUser,Profile,Style and the favorited Tweet.
Before early 2009, produced TwitterUserPartials, not full records
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
-
#healthy? ⇒ Boolean
Extracted JSON should be an array.
- #items_count(thing) ⇒ Object
-
#parse(*args, &block) ⇒ Object
unpacks the raw API response, yielding all the interesting objects and relationships within.
-
#set_total_items(twitter_user_info) ⇒ Object
set max_total_items from the favourites_count.
Methods inherited from Base
#key, #make_url, #num_items, #request_for_page, #response=
Instance Method Details
#healthy? ⇒ Boolean
Extracted JSON should be an array
107 108 109 |
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 107 def healthy?() parsed_contents && parsed_contents.is_a?(Array) end |
#items_count(thing) ⇒ Object
104 |
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 104 def items_count(thing) thing.favourites_count end |
#parse(*args, &block) ⇒ Object
unpacks the raw API response, yielding all the interesting objects and relationships within.
120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 120 def parse *args, &block return unless healthy? parsed_contents.each do |hsh| json_obj = JsonTweetWithUser.new(hsh, 'scraped_at' => scraped_at) next unless json_obj && json_obj.healthy? # # Extract user, tweet and relationship yield AFavoritesB.new(self.twitter_user_id, json_obj.user.id, json_obj.tweet.id) if json_obj.user && json_obj.tweet json_obj.each(&block) end end |
#set_total_items(twitter_user_info) ⇒ Object
set max_total_items from the favourites_count.
112 113 114 |
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 112 def set_total_items twitter_user_info self.max_total_items = twitter_user_info['favourites_count'].to_i rescue nil end |