Class: AllTweets::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/alltweets/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Fetcher

Returns a new instance of Fetcher.



5
6
7
8
9
10
11
12
# File 'lib/alltweets/fetcher.rb', line 5

def initialize(arg)
  @client = case arg
  when Hash
    Twitter::REST::Client.new(arg)
  else
    arg
  end
end

Instance Method Details

#fetch_all_tweets(user, include_retweets: true) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/alltweets/fetcher.rb', line 14

def fetch_all_tweets(user, include_retweets: true)
  collect_with_max_id do |max_id|
    options = {count: 200, include_rts: include_retweets}
    options[:max_id] = max_id unless max_id.nil?
    @client.user_timeline(user, options)
  end
end