class Tomodachi::Client
Public Class Methods
new(screen_name)
click to toggle source
# File lib/tomodachi/client.rb, line 4 def initialize(screen_name) @screen_name = screen_name end
Public Instance Methods
start()
click to toggle source
# File lib/tomodachi/client.rb, line 8 def start unless account puts "#{screen_name} is not authenticated." return end configure(account) client.user do |status| if status['event'] == 'follow' && status['source']['screen_name'] != @screen_name puts "followed #{status['source']['screen_name']}" Twitter.follow(status['source']['id']) end end end
Private Instance Methods
account()
click to toggle source
# File lib/tomodachi/client.rb, line 45 def account return @account if @account accounts = auth.load_config @account = accounts.find { |account| account[:screen_name] == @screen_name } end
account_exists?(screen_name)
click to toggle source
# File lib/tomodachi/client.rb, line 52 def account_exists?(screen_name) accounts = auth.load_config accounts.find { |account| account[:screen_name] == screen_name } end
auth()
click to toggle source
# File lib/tomodachi/client.rb, line 57 def auth @auth ||= Tomodachi::Auth.new end
client()
click to toggle source
# File lib/tomodachi/client.rb, line 25 def client @client ||= UserStream.client end
configure(account)
click to toggle source
# File lib/tomodachi/client.rb, line 29 def configure(account) UserStream.configure do |config| config.consumer_key = Tomodachi::CONSUMER_KEY config.consumer_secret = Tomodachi::CONSUMER_SECRET config.oauth_token = account[:access_token] config.oauth_token_secret = account[:access_token_secret] end Twitter.configure do |config| config.consumer_key = Tomodachi::CONSUMER_KEY config.consumer_secret = Tomodachi::CONSUMER_SECRET config.oauth_token = account[:access_token] config.oauth_token_secret = account[:access_token_secret] end end