class Tweep::Account

Public Class Methods

each(&block) click to toggle source
# File lib/tweep/account.rb, line 14
def self.each(&block)
  @@registry.values.each(&block)
end
find(nick) click to toggle source
# File lib/tweep/account.rb, line 18
def self.find(nick)
  @@registry[nick]
end
new(yml, index) click to toggle source
# File lib/tweep/account.rb, line 22
def initialize(yml, index)
  return unless load_config(yml, index)
  @index = index
  @@registry[@config.nick] = self
end

Public Instance Methods

retweet!(status_id) click to toggle source
# File lib/tweep/account.rb, line 28
def retweet!(status_id)
  Tweep.info "#{@config.nick} retweets #{status_id.inspect}"
  execute :retweet, status_id
end
run!() click to toggle source
# File lib/tweep/account.rb, line 33
def run!
  return unless @config.has_tweets? && @config.now_is_a_good_time?
  tweet!
end

Private Instance Methods

execute(call, *args) click to toggle source
# File lib/tweep/account.rb, line 39
def execute(call, *args)
  Twitter.configure do |config|
    @config.auth.each do |k, v|
      config.send("#{k}=", v)
    end
  end
  Twitter.send(call, *args)
end
load_config(file, index) click to toggle source
# File lib/tweep/account.rb, line 48
def load_config(file, index)
  return unless File.file?(file) && File.readable_real?(file)
  @config = Config.new(file, index)
  @config.has_auth?
end
tweet!() click to toggle source
# File lib/tweep/account.rb, line 54
def tweet!
  status, idx = @config.next_tweet
  return if status.blank?
  Tweep.info "#{@config.nick} tweets: #{status}"
  st = execute(:update, status)
  @index.tweeted! @config.nick, idx
  @config.retweeters.each do |retweeter, _|
    if @config.should_get_retweeted_by?(retweeter)
      self.class.find(retweeter).try(:retweet!, st.id)
    end
  end
end