class Chizuru::Bot

Represents a twitter-bot.

Attributes

credential[RW]

Gets or sets credentials. (This is given to the source.)

provider[RW]

Gets or sets a provider.

src[RW]

Gets or sets a source.

Public Class Methods

configure(cred_path, &block) click to toggle source

Configures this bot.

# File lib/chizuru/bot.rb, line 34
def self.configure(cred_path, &block)
  bot = Bot.new
  bot.credential = Credential.new(cred_path)
  bot.provider = Provider.new
  bot.instance_eval &block
  bot
end

Public Instance Methods

consumer(cons, *init_args, &block) click to toggle source

Adds a consumer.

  • If an instance of Consumer or its subclasses is given, it is used.

  • If Class is given, initialize its instance, and use it. In this case, the rest arguments are passed to the constructor of the given class.

# File lib/chizuru/bot.rb, line 46
def consumer(cons, *init_args, &block)
  if cons.instance_of? Class
    cons = cons.new(*init_args)
  end
  ch = ConsumerHelper.new(cons, credential)
  ch.instance_eval &block
  provider.add_consumer(ch.consumer)
end
source(src) click to toggle source

Sets a source.

# File lib/chizuru/bot.rb, line 56
def source(src)
  @source = src
end
start() click to toggle source

Starts this bot.

# File lib/chizuru/bot.rb, line 61
def start
  @source.start
end