Class: Coffeemaker::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/coffeemaker/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
13
14
# File 'lib/coffeemaker/runner.rb', line 8

def initialize(argv)
  @options = default_options
  parse_options!(argv)
  @logger = Logger.new(@options.delete(:logfile))
  @logger.level = @options.delete(:log_level)
  @channels = @options.delete(:channels)
end

Instance Method Details

#startObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/coffeemaker/runner.rb', line 16

def start
  EM.run do
    bot = Coffeemaker::Bot.new(@options.merge(:logger => @logger))
    bot.start do |irc|
      @channels.each { |channel| irc.join(channel) }
    end

    trap ("INT") do
      bot.stop
      EM.stop
    end
  end
end