Module: TwitterSearchPhotos
- Defined in:
- lib/twitter_search_photos.rb,
lib/twitter_search_photos/version.rb
Constant Summary collapse
- VERSION =
"0.0.6"
- @@configured =
false
Class Method Summary collapse
-
.make_results(tweets) ⇒ Object
make our results structure.
-
.search(query, options = {}) ⇒ Object
Can be optionally called with since_id: max_id.
Class Method Details
.make_results(tweets) ⇒ Object
make our results structure
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/twitter_search_photos.rb', line 19 def self.make_results(tweets) results = [] tweets.each do |tweet| tweet.media.each do |media| if media.is_a?(Twitter::Media::Photo) result = OpenStruct.new( media_url: media.media_url, display_url: "https://#{media.display_url}", screen_name: tweet.user.screen_name, # Twitter returns a Time object, I want a DateTime created_at: DateTime.parse(tweet.created_at.to_s) ) results << result end end end results end |
.search(query, options = {}) ⇒ Object
Can be optionally called with since_id: max_id
10 11 12 13 14 15 16 |
# File 'lib/twitter_search_photos.rb', line 10 def self.search(query, = {}) configure! .merge!(include_entities: 1) search = Twitter.search(query, ) results = make_results(search.results) response = OpenStruct.new(max_id: search.max_id, results: results) end |