Class: SubSpawn::Internal::FdSource::Pipe

Inherits:
Open show all
Defined in:
lib/subspawn/fd_types.rb

Instance Attribute Summary

Attributes inherited from SubSpawn::Internal::FdSource

#all_dests, #dests

Instance Method Summary collapse

Methods inherited from SubSpawn::Internal::FdSource

#before?, #depends?, #destroys?, #heads, #max, #raw_apply, #tails, #to_dbg

Constructor Details

#initialize(dests, dir) ⇒ Pipe

Returns a new instance of Pipe.



121
122
123
124
# File 'lib/subspawn/fd_types.rb', line 121

def initialize(dests, dir)
  super(dests)
  @dir = dir
end

Instance Method Details

#apply(base) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/subspawn/fd_types.rb', line 125

def apply base
  @saved ||= IO.pipe
  r, w = {read: @saved, write: @saved.reverse}[@dir]
  raw_apply base, r
  @dests.each {|dest| base.fd_close(w) } # if you want the other end, pass it in yourself

  SubSpawn::IoHolder::Pipe.new(w, r)
end