Class: Roflbot::Runner

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

Instance Method Summary collapse

Constructor Details

#initialize(argv = ARGV) ⇒ Runner

Returns a new instance of Runner.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/roflbot/runner.rb', line 3

def initialize(argv = ARGV)
  @config = nil
  OptionParser.new do |opts|
    opts.on("-c", "--config FILENAME") { |c| @config = c }
  end.parse!(argv)

  @bot = SentenceBot.new(YAML.load_file(@config))
  Signal.trap("INT") { stop }
  @bot.start
  @bot.wait
end

Instance Method Details

#stopObject



15
16
17
18
# File 'lib/roflbot/runner.rb', line 15

def stop
  @bot.stop
  File.open(@config, "w") { |f| f.write(@bot.options.to_yaml) }
end