Class: TweetFinder
- Inherits:
-
Object
- Object
- TweetFinder
- Defined in:
- lib/finders/tweet_finder.rb
Instance Method Summary collapse
- #find_tweet(query) ⇒ Object
- #find_tweets ⇒ Object
-
#initialize(client, topics) ⇒ TweetFinder
constructor
A new instance of TweetFinder.
Constructor Details
#initialize(client, topics) ⇒ TweetFinder
Returns a new instance of TweetFinder.
2 3 4 5 |
# File 'lib/finders/tweet_finder.rb', line 2 def initialize(client, topics) @client = client @topics = topics end |
Instance Method Details
#find_tweet(query) ⇒ Object
13 14 15 |
# File 'lib/finders/tweet_finder.rb', line 13 def find_tweet(query) @client.search(query) end |
#find_tweets ⇒ Object
7 8 9 10 11 |
# File 'lib/finders/tweet_finder.rb', line 7 def find_tweets @topics.reduce([]) do |t, topic| t << Thread.new(topic) { |topic| find_tweet(topic) } end.each { |t| t.join }.map { |t| t.value } end |