Class: ZooniverseSocial::Tweets
- Inherits:
-
Object
- Object
- ZooniverseSocial::Tweets
- Defined in:
- lib/zooniverse_social/tweets.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize ⇒ Tweets
constructor
A new instance of Tweets.
- #update ⇒ Object
Constructor Details
#initialize ⇒ Tweets
Returns a new instance of Tweets.
7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/zooniverse_social/tweets.rb', line 5 def data @data end |
Instance Method Details
#update ⇒ Object
16 17 18 19 20 21 22 23 |
# 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 |