Class: Wuclan::Twitter::Scrape::TwitterFriendsRequest

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 friends.

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

Before early 2009, produced TwitterUserPartials, not full records

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

Direct Known Subclasses

Friends

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)


69
70
71
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 69

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

#items_count(thing) ⇒ Object



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

def items_count(thing) thing.friends_count end

#parse(*args, &block) ⇒ Object

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



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 77

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(self.twitter_user_id, json_obj.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 friends_count.



64
65
66
# File 'lib/wuclan/twitter/scrape/twitter_followers_request.rb', line 64

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