What exactly does CSV do? (I know its a gem)
What is SLICE_SIZE? (Line 13)
Why is csv insided straight braces?(Line 16) CSV do |csv|
Can You explain the whole lines 17, 18, 19?I am completely lost on that?
-----------------Code--------------------------------------------------
require 'twitter'
require 'csv'
def twitter_client
@twitter_client ||= Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
end
SLICE_SIZE = 100
def fetch_all_friends(twitter_username)
CSV do|csv|
twitter_client.follower_ids(twitter_username).each_slice
(SLICE_SIZE).with_index do |slice, i|
twitter_client.users(slice).each_with_index do |f, j|
csv << [i * SLICE_SIZE + j + 1, f.name,
f.screen_name]
end
end
end
end