module TwitterWithAutoPagination::Collector
Public Instance Methods
collect_with_cursor(collection = [], cursor = nil) { |cursor| ... }
click to toggle source
# File lib/twitter_with_auto_pagination/collector.rb, line 11 def collect_with_cursor(collection = [], cursor = nil, &block) response = yield(cursor) return collection if response.nil? # Notice: If you call response.to_a, it automatically fetch all results and the results are not cached. collection += (response.attrs[:ids] || response.attrs[:users] || response.attrs[:lists]) response.attrs[:next_cursor].zero? ? collection.flatten : collect_with_cursor(collection, response.attrs[:next_cursor], &block) end
collect_with_max_id(collection = [], max_id = nil) { |max_id| ... }
click to toggle source
# File lib/twitter_with_auto_pagination/collector.rb, line 4 def collect_with_max_id(collection = [], max_id = nil, &block) tweets = yield(max_id) return collection if tweets.nil? collection += tweets tweets.empty? ? collection.flatten : collect_with_max_id(collection, tweets.last.id - 1, &block) end