Class: TwitterRequestStream
- Inherits:
-
Monkeyshines::RequestStream::SimpleRequestStream
- Object
- Monkeyshines::RequestStream::SimpleRequestStream
- TwitterRequestStream
- Defined in:
- lib/wuclan/twitter/scrape/twitter_request_stream.rb
Constant Summary collapse
Instance Method Summary collapse
-
#each(*args, &block) ⇒ Object
for the given user_id, gets the user and then each of the requests in more_request_klasses.
-
#each_request(twitter_user_id, *args) {|user_req| ... } ⇒ Object
Get the user and then get all other requested classes.
-
#initialize(_options = {}) ⇒ TwitterRequestStream
constructor
A new instance of TwitterRequestStream.
-
#request_klasses=(klass_names) ⇒ Object
Set the list of follow-on requests ‘followers_ids,friends_ids’.
Constructor Details
#initialize(_options = {}) ⇒ TwitterRequestStream
Returns a new instance of TwitterRequestStream.
6 7 8 9 |
# File 'lib/wuclan/twitter/scrape/twitter_request_stream.rb', line 6 def initialize ={} super self.request_klasses = [:fetches] end |
Instance Method Details
#each(*args, &block) ⇒ Object
for the given user_id, gets the user and then each of the requests in more_request_klasses
39 40 41 42 43 |
# File 'lib/wuclan/twitter/scrape/twitter_request_stream.rb', line 39 def each *args, &block request_store.each do |*raw_job_args| self.each_request(*raw_job_args, &block) end end |
#each_request(twitter_user_id, *args) {|user_req| ... } ⇒ Object
Get the user and then get all other requested classes. The user’s parameters (followers_count, etc.) fix the items to request The users’ numeric ID replaces the supplied identifier (the first request can be a screen_name, but we need the numeric ID for followers_request’s, etc.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wuclan/twitter/scrape/twitter_request_stream.rb', line 22 def each_request twitter_user_id, *args user_req = TwitterUserRequest.new(twitter_user_id) yield(user_req) return unless user_req.healthy? twitter_user_id = user_req.parsed_contents['id'].to_i if (user_req.parsed_contents['id'].to_i > 0) @request_klasses.each do |request_klass| req = request_klass.new(twitter_user_id) req.set_total_items user_req.parsed_contents yield req end end |
#request_klasses=(klass_names) ⇒ Object
Set the list of follow-on requests
'followers_ids,friends_ids'
13 14 15 16 |
# File 'lib/wuclan/twitter/scrape/twitter_request_stream.rb', line 13 def request_klasses=(klass_names) @request_klasses = FactoryModule.list_of_classes(DEFAULT_REQUEST_SCOPE, klass_names, 'twitter', 'request').to_set @request_klasses.delete TwitterUserRequest end |