lib/alltweets/fetcher.rb in alltweets-1.1.3 vs lib/alltweets/fetcher.rb in alltweets-2.0.0
- old
+ new
@@ -1,27 +1,28 @@
require "twitter"
module AllTweets
class Fetcher
def initialize(arg)
- case arg
+ @client = case arg
when Hash
- @client = Twitter::REST::Client.new(arg)
+ Twitter::REST::Client.new(arg)
else
- @client = arg
+ arg
end
end
def fetch_all_tweets(user, include_retweets: true)
collect_with_max_id do |max_id|
- options = { count: 200, include_rts: include_retweets }
+ options = {count: 200, include_rts: include_retweets}
options[:max_id] = max_id unless max_id.nil?
@client.user_timeline(user, options)
end
end
private
- def collect_with_max_id(collection=[], max_id = nil, &block)
+
+ def collect_with_max_id(collection = [], max_id = nil, &block)
response = yield(max_id)
collection += response
if response.empty?
collection.flatten
else