Module: TwitterFriendly::REST::Collector
- Included in:
- API
- Defined in:
- lib/twitter_friendly/rest/collector.rb
Instance Method Summary collapse
- #fetch_resources_with_cursor(method_name, *args) ⇒ Object
- #fetch_tweets_with_max_id(method_name, max_count, *args) ⇒ Object
Instance Method Details
#fetch_resources_with_cursor(method_name, *args) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/twitter_friendly/rest/collector.rb', line 18 def fetch_resources_with_cursor(method_name, *args) = args.dup. collect_with_cursor([], -1) do |next_cursor| [:cursor] = next_cursor unless next_cursor.nil? send(method_name, *args) end end |
#fetch_tweets_with_max_id(method_name, max_count, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/twitter_friendly/rest/collector.rb', line 4 def fetch_tweets_with_max_id(method_name, max_count, *args) = args.dup. total_count = .delete(:count) || max_count call_count = total_count / max_count + (total_count % max_count == 0 ? 0 : 1) [:count] = [max_count, total_count].min = {call_count: call_count, total_count: total_count} collect_with_max_id([], nil, ) do |max_id| [:max_id] = max_id unless max_id.nil? send(method_name, *args) end end |