class ProcessExecuter::Destinations::IO

Handles IO objects

@api private

Public Class Methods

handles?(destination) click to toggle source

Determines if this class can handle the given destination

@param destination [Object] the destination to check @return [Boolean] true if destination is an IO with a valid file descriptor

# File lib/process_executer/destinations/io.rb, line 33
def self.handles?(destination)
  destination.is_a?(::IO) && destination.respond_to?(:fileno) && destination.fileno
end

Public Instance Methods

write(data) click to toggle source

Writes data to the IO object

@example

io = File.open('file.txt', 'w')
io_handler = ProcessExecuter::Destinations::IO.new(io)
io_handler.write("Hello world")

@param data [String] the data to write

@return [Integer] the number of bytes written

@raise [IOError] if the IO object is closed

# File lib/process_executer/destinations/io.rb, line 24
def write(data)
  super
  destination.write data
end