module TwitterFriendly::REST::FriendsAndFollowers

Constants

MAX_IDS_PER_REQUEST

Public Instance Methods

follower_ids(*args) click to toggle source
# File lib/twitter_friendly/rest/friends_and_followers.rb, line 31
def follower_ids(*args)
  options = {count: MAX_IDS_PER_REQUEST}.merge(args.extract_options!)
  args << options

  if options.has_key?(:cursor)
    @twitter.follower_ids(*args)&.attrs
  else
    fetch_resources_with_cursor(__method__, *args)
  end
end
followers(*args) click to toggle source
# File lib/twitter_friendly/rest/friends_and_followers.rb, line 55
def followers(*args)
  ids = follower_ids(*args)
  users(ids)
end
friend_ids(*args) click to toggle source

@return [Hash]

@overload friend_ids(options = {}) @overload friend_ids(user, options = {})

@param user [Integer, String] A Twitter user ID or screen name.

@option options [Integer] :count The number of tweets to return per page, up to a maximum of 5000.

# File lib/twitter_friendly/rest/friends_and_followers.rb, line 20
def friend_ids(*args)
  options = {count: MAX_IDS_PER_REQUEST}.merge(args.extract_options!)
  args << options

  if options.has_key?(:cursor)
    @twitter.friend_ids(*args)&.attrs
  else
    fetch_resources_with_cursor(__method__, *args)
  end
end
friend_ids_and_follower_ids(*args) click to toggle source
# File lib/twitter_friendly/rest/friends_and_followers.rb, line 60
def friend_ids_and_follower_ids(*args)
  parallel(in_threads: 2) do |batch|
    batch.friend_ids(*args)
    batch.follower_ids(*args)
  end
end
friends(*args) click to toggle source

@return [Hash]

@overload friends(options = {}) @overload friends(user, options = {})

@param user [Integer, String] A Twitter user ID or screen name.

@option options [Bool] :parallel

# File lib/twitter_friendly/rest/friends_and_followers.rb, line 50
def friends(*args)
  ids = friend_ids(*args)
  users(ids)
end
friends_and_followers(*args) click to toggle source
# File lib/twitter_friendly/rest/friends_and_followers.rb, line 67
def friends_and_followers(*args)
  following_ids, followed_ids = friend_ids_and_follower_ids(*args)
  people = users((following_ids + followed_ids).uniq).index_by { |u| u[:id] }
  [people.slice(*following_ids).values, people.slice(*followed_ids).values]
end
friendship?(from, to, options = {}) click to toggle source
# File lib/twitter_friendly/rest/friends_and_followers.rb, line 6
def friendship?(from, to, options = {})
  @twitter.send(__method__, from, to, options)
end