Sha256: 261159b27635a6ee4543b2685eda82787d58577fdf945e99e0dfb4e5ae0a232b

Contents?: true

Size: 588 Bytes

Versions: 8

Compression:

Stored size: 588 Bytes

Contents

require 'twitter'

module ZooniverseSocial
  class Tweets
    attr_reader :data

    def initialize
      @twitter = Twitter::REST::Client.new({
        consumer_key: ENV.fetch('TWITTER_KEY'),
        consumer_secret: ENV.fetch('TWITTER_SECRET')
      })

      update
    end

    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zooniverse_social-1.2.0 lib/zooniverse_social/tweets.rb
zooniverse_social-1.1.0 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.6 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.5 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.4 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.3 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.2 lib/zooniverse_social/tweets.rb
zooniverse_social-1.0.1 lib/zooniverse_social/tweets.rb