lib/augury/fortune.rb in augury-1.0.1 vs lib/augury/fortune.rb in augury-1.0.2
- old
+ new
@@ -15,26 +15,27 @@
def collect_with_max_id(collection = [], max_id = nil, &block)
response = yield(max_id)
collection += response
if response.empty?
- collection.flatten
+ collection
elsif !@config[:count].zero? && collection.length >= @config[:count]
- collection.flatten
+ # Get everything or trim the results to the count
+ @config[:count].zero? ? collection : collection[0..@config[:count] - 1]
else
collect_with_max_id(collection, response.last.id - 1, &block)
end
end
def retrieve_tweets
- collect_with_max_id do |max_id|
+ @tweets = collect_with_max_id do |max_id|
options = {
- count: @config[:count].zero? ? 200 : @config[:count],
+ count: 200,
include_rts: @config[:retweets],
exclude_replies: !@config[:replies],
}
options[:max_id] = max_id unless max_id.nil?
- @tweets = @twitter.user_timeline(@username, options)
+ @twitter.user_timeline(@username, options)
end
rescue Twitter::Error::TooManyRequests => e
reset_length = e.rate_limit.reset_in + 1
puts "Twitter rate limit exceeded. Waiting #{reset_length} minute(s)"
sleep reset_length