class IOP::IOWriter

Sink class to write received upstream data to external IO stream.

Contrary to {FileWriter}, this class does not manage attached IO instance, e.g. it makes no attempt to close it after processing.

### Use case: concatenate two files.

require 'iop/file'
io = File.new('output.dat', 'wb')
begin
  ( IOP::FileReader.new('file1.dat') | IOP::IOWriter.new(io) ).process!
  ( IOP::FileReader.new('file2.dat') | IOP::IOWriter.new(io) ).process!
ensure
  io.close
end

@since 0.1

Public Class Methods

new(io) click to toggle source

Creates class instance.

@param io [IO] IO instance to write data to

# File lib/iop/file.rb, line 117
def initialize(io)
  @io = io
end

Public Instance Methods

process(data = nil) click to toggle source
# File lib/iop/file.rb, line 121
def process(data = nil)
  @io.write(data)
end