class ReplacerBot::Replacer

Attributes

client[R]
config[R]
results[R]

Public Class Methods

new() click to toggle source
# File lib/replacer_bot/replacer.rb, line 5
def initialize
  @config = Config.instance.config
  @search_term = @config.search_term
  @client = TwitterClient.client
end

Public Instance Methods

save() click to toggle source
# File lib/replacer_bot/replacer.rb, line 36
def save
  if search.first

    File.open @config.save_file, 'w' do |file|
      Marshal.dump search.first.id, file
    end
  end
end
tweet(dry_run: false, chatty: false) click to toggle source
# File lib/replacer_bot/replacer.rb, line 21
def tweet dry_run: false, chatty: false
  tweets.each_with_index do |tweet, index|
    puts "Tweeting: #{tweet}" if chatty
    @client.update tweet unless dry_run
    unless dry_run
    #  unless index == tweets.count - 1
        puts "Sleeping #{@config.interval} seconds" if chatty
        sleep @config.interval
    #  end
    end
  end

  save unless dry_run
end
tweets() click to toggle source
# File lib/replacer_bot/replacer.rb, line 17
def tweets
  search.map { |r| ReplacerBot.truncate ReplacerBot.title_case ReplacerBot.encode_entities ReplacerBot.replace string: r.text }
end