class ZooniverseSocial::Tweets
Attributes
data[R]
Public Class Methods
new()
click to toggle source
# File lib/zooniverse_social/tweets.rb, line 7 def initialize @twitter = Twitter::REST::Client.new({ consumer_key: ENV.fetch('TWITTER_KEY'), consumer_secret: ENV.fetch('TWITTER_SECRET') }) update end
Public Instance Methods
update()
click to toggle source
# File lib/zooniverse_social/tweets.rb, line 16 def update @data = @twitter.search('from:the_zooniverse', result_type: 'recent').take(3).collect do |tweet| tweet.to_h.tap do |hash| appended = hash.dig :entities, :urls, 0, :url hash[:text].sub!(/\s?#{ appended }/, '') if appended end end end