Class: Mutant::Pipe Private

Inherits:
Object
  • Object
show all
Includes:
Unparser::Adamantium
Defined in:
lib/mutant/pipe.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Pipe abstraction

Defined Under Namespace

Classes: Connection

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_io(io) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
# File 'lib/mutant/pipe.rb', line 17

def self.from_io(io)
  reader, writer = io.pipe(binmode: true)
  new(reader: reader, writer: writer)
end

.with(io) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Run block with pipe in binmode

Returns:

  • (undefined)


11
12
13
14
15
# File 'lib/mutant/pipe.rb', line 11

def self.with(io)
  io.pipe(binmode: true) do |(reader, writer)|
    yield new(reader: reader, writer: writer)
  end
end

Instance Method Details

#to_readerIO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parent reader end of the pipe

Returns:

  • (IO)


33
34
35
36
# File 'lib/mutant/pipe.rb', line 33

def to_reader
  writer.close
  reader
end

#to_writerIO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Writer end of the pipe

Returns:

  • (IO)


25
26
27
28
# File 'lib/mutant/pipe.rb', line 25

def to_writer
  reader.close
  writer
end