Class: Hallmonitor::Outputters::IOOutputter

Inherits:
Hallmonitor::Outputter show all
Defined in:
lib/hallmonitor/outputters/iooutputter.rb

Overview

Simple outputter that just prints to an output stream

Instance Attribute Summary

Attributes inherited from Hallmonitor::Outputter

#name

Instance Method Summary collapse

Constructor Details

#initialize(name, out) ⇒ IOOutputter

Builds a new IOOutputter

Parameters:

  • name (String)

    Name for this outputter

  • out (IO)

    Output to write to



11
12
13
14
# File 'lib/hallmonitor/outputters/iooutputter.rb', line 11

def initialize(name, out)
  super(name)
  @out = out
end

Instance Method Details

#process(event) ⇒ Object

Sends an event to the configured output on IOError the output will be closed



18
19
20
21
22
23
24
25
# File 'lib/hallmonitor/outputters/iooutputter.rb', line 18

def process(event)
  begin
    @out.print "EVENT: #{event.to_json}\n"
    @out.flush
  rescue IOError => e
    close
  end
end