lib/hallmonitor/outputters/iooutputter.rb in hallmonitor-1.1.0 vs lib/hallmonitor/outputters/iooutputter.rb in hallmonitor-2.0.0

- old
+ new

@@ -2,11 +2,10 @@ module Hallmonitor module Outputters # Simple outputter that just prints to an output stream class IOOutputter < Outputter - # Builds a new IOOutputter # @param name [String] Name for this outputter # @param out [IO] Output to write to def initialize(name, out) super(name) @@ -14,18 +13,17 @@ end # Sends an event to the configured output # on IOError the output will be closed def process(event) - begin - @out.print "EVENT: #{event.to_json}\n" - @out.flush - rescue IOError => e - close - end + @out.print "EVENT: #{event.to_json}\n" + @out.flush + rescue IOError + close end private + def close @out.close unless @out.nil? end end end