Ruby - compile fail , empty error dump
- Updated Thursday, July 24th 2014 @ 17:03:05
Hey all i am trying to test a simple bot written in ruby and i cant seem to find what is wrong...
I guess something to do with input and output but cant figure it out.
Here is the sample code for a bot that just checks
class bot #.... def run while $stdin.closed? == false line = $stdin.gets $stderr.puts 'in loop' next if line.empty? Engine.parse(line) if Engine.action? $stderr.puts 'action time!' check $stdout.flush end end end end STDERR.puts "it runs" testbot = Bot.new testbot.run
- Created Thursday, July 24th 2014 @ 17:23:57
i tried with something even simpler and still fails with empty error dump
while $stdin.closed? == false line = $stdin.gets $stderr.puts 'in loop' next if line.empty? line = line.split(' ').map {|x| x.downcase} if line[0] == 'action' $stderr.puts 'action time!' $stdout.puts 'check 0' $stdout.flush end end
- Updated Thursday, July 24th 2014 @ 20:10:38
Thanks jim it works fine now.
For anyone wondering: put #!/usr/bin/env ruby at the top of the init file and enclose the running method like this: if FILE == $0 Bot.run end