Class: Wuclan::Twitter::Scrape::TwitterFriendsIdsRequest

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

Overview

API request for the full list of a user’s friends (IDs only). One call gives the whole list.

Produces a (possibly very large) number of AFollowsB.

Direct Known Subclasses

FriendsIds

Constant Summary

Constants inherited from Base

Base::BAD_CHARS

Instance Method Summary collapse

Methods inherited from Base

#num_items, #request_for_page, #response=, #set_total_items

Instance Method Details

#healthy?Boolean

friends_ids should be an array of user_id’s

Returns:

  • (Boolean)


58
59
60
# File 'lib/wuclan/twitter/scrape/twitter_ff_ids_request.rb', line 58

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

#items_count(thing) ⇒ Object



49
# File 'lib/wuclan/twitter/scrape/twitter_ff_ids_request.rb', line 49

def items_count(thing) thing.friends_count == 0 ? 0 : 1 end

#keyObject



51
52
53
# File 'lib/wuclan/twitter/scrape/twitter_ff_ids_request.rb', line 51

def key
  twitter_user_id
end

#make_urlObject



50
# File 'lib/wuclan/twitter/scrape/twitter_ff_ids_request.rb', line 50

def make_url() "http://twitter.com/#{resource_path}/#{twitter_user_id}.json"  end

#parse(*args, &block) ⇒ Object

unpacks the raw API response, yielding all the relationships.



65
66
67
68
69
70
71
72
# File 'lib/wuclan/twitter/scrape/twitter_ff_ids_request.rb', line 65

def parse *args, &block
  return unless healthy?
  parsed_contents.each do |user_b_id|
    user_b_id = "%010d"%user_b_id.to_i
    # B is a friend: user follows B
    yield AFollowsB.new(twitter_user_id, user_b_id)
  end
end