Class: Gallus::Output::Stream
- Inherits:
-
Object
- Object
- Gallus::Output::Stream
- Defined in:
- lib/gallus/output/stream.rb
Instance Method Summary collapse
- #call(event) ⇒ Object
- #call!(event) ⇒ Object
-
#initialize(stream, format) ⇒ Stream
constructor
A new instance of Stream.
Constructor Details
#initialize(stream, format) ⇒ Stream
Returns a new instance of Stream.
4 5 6 7 |
# File 'lib/gallus/output/stream.rb', line 4 def initialize(stream, format) @mutex = Mutex.new @stream, @format = stream, format end |
Instance Method Details
#call(event) ⇒ Object
9 10 11 |
# File 'lib/gallus/output/stream.rb', line 9 def call(event) @mutex.synchronize { call!(event) } end |
#call!(event) ⇒ Object
13 14 15 |
# File 'lib/gallus/output/stream.rb', line 13 def call!(event) @stream.write(@format.call(event) + "\n") end |