class TwitterClient
Public Class Methods
new(twitter_config)
click to toggle source
# File lib/clients/twitter_client.rb, line 2 def initialize(twitter_config) @rest_client = Twitter::REST::Client.new do |config| config.consumer_key = twitter_config.consumer_key config.consumer_secret = twitter_config.consumer_secret config.access_token = twitter_config.access_token config.access_token_secret = twitter_config.access_token_secret end @username = twitter_config.username end
Public Instance Methods
follow(user)
click to toggle source
# File lib/clients/twitter_client.rb, line 29 def follow(user) @rest_client.follow(user) end
random_follower_of_random_follower()
click to toggle source
# File lib/clients/twitter_client.rb, line 12 def random_follower_of_random_follower follower = @rest_client.followers.attrs[:users].sample[:screen_name] @rest_client.friend_ids(follower).attrs[:ids].sample if follower end
search(query)
click to toggle source
# File lib/clients/twitter_client.rb, line 25 def search(query) @rest_client.search("#{query} -rt -from:#{@username}", { lang: 'en' }).first.text end
update(text)
click to toggle source
# File lib/clients/twitter_client.rb, line 21 def update(text) @rest_client.update(text) end
update_with_media(text, image_file)
click to toggle source
# File lib/clients/twitter_client.rb, line 17 def update_with_media(text, image_file) @rest_client.update_with_media(text, image_file) end