Class: Roflbot::Runner
- Inherits:
-
Object
- Object
- Roflbot::Runner
- Defined in:
- lib/roflbot/runner.rb
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Runner
constructor
A new instance of Runner.
- #stop ⇒ Object
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
#stop ⇒ Object
15 16 17 18 |
# File 'lib/roflbot/runner.rb', line 15 def stop @bot.stop File.open(@config, "w") { |f| f.write(@bot..to_yaml) } end |