class TweetManager::Tweet
Tweet
content
Constants
- AVALAIBLE_SERVICES
- TYPES
Public Class Methods
new(credentials, youtube_api_key)
click to toggle source
# File lib/tweet_manager.rb, line 12 def initialize(credentials, youtube_api_key) @client = Twitter::REST::Client.new do |config| config.consumer_key = credentials[:consumer_key] config.consumer_secret = credentials[:consumer_secret] config.access_token = credentials[:access_token] config.access_token_secret = credentials[:access_token_secret] end @youtube_api_key = youtube_api_key end
Public Instance Methods
action(service:, type:, target:, extras: [])
click to toggle source
# File lib/tweet_manager.rb, line 22 def action(service:, type:, target:, extras: []) raise 'Non existing service' unless AVALAIBLE_SERVICES.include? service raise 'Non existing type' unless TYPES.include? type result = send(service).send("#{type}_content", target) update(result, extras) end
Private Instance Methods
medium()
click to toggle source
# File lib/tweet_manager.rb, line 36 def medium @medium ||= Medium.new end
update(args, extras)
click to toggle source
# File lib/tweet_manager.rb, line 31 def update(args, extras) msg = "#{args[:title]} #{args[:url]} #{extras.join(' ')}" @client.update(msg) end
youtube()
click to toggle source
# File lib/tweet_manager.rb, line 40 def youtube @youtube ||= Youtube.new @youtube_api_key end