Class: Wuclan::Twitter::Scrape::TwitterFollowersRequest

Inherits:
Base
  • Object
show all
Defined in:
lib/wuclan/twitter/scrape/twitter_followers_request.rb

Overview

API request for the timeline from a user’s followers.

Produces max 100 TwitterUser,Profile,Style, their most recent Tweet, and an AFollowsB link

Before early 2009, produced TwitterUserPartials, not full records

apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0followers

Direct Known Subclasses

Followers

Constant Summary

Constants inherited from Base

Base::BAD_CHARS

Instance Method Summary collapse

Methods inherited from Base

#key, #make_url, #num_items, #request_for_page, #response=

Instance Method Details

#healthy?Boolean

Extracted JSON should be an array

Returns:

  • (Boolean)


27
28
29
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 27

def healthy?()
  parsed_contents && parsed_contents.is_a?(Array)
end

#items_count(thing) ⇒ Object



19
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 19

def items_count(thing) thing.followers_count end

#parse(*args, &block) ⇒ Object

unpacks the raw API response, yielding all the interesting objects and relationships within.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 35

def parse *args, &block
  return unless healthy?
  parsed_contents.each do |hsh|
    json_obj = JsonUserWithTweet.new(hsh, 'scraped_at' => scraped_at)
    next unless json_obj && json_obj.healthy?
    #
    # Extract user, tweet and relationship
    yield AFollowsB.new(json_obj.user.id, self.twitter_user_id) if json_obj.user
    json_obj.each(&block)
  end
end

#set_total_items(twitter_user_info) ⇒ Object

set max_total_items from the favourites_count.



22
23
24
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 22

def set_total_items 
  self.max_total_items = ['followers_count'].to_i rescue nil
end