class ProcessExecuter::Destinations::FileDescriptor
Handles numeric file descriptors
@api private
Public Class Methods
Source
# File lib/process_executer/destinations/file_descriptor.rb, line 35 def self.handles?(destination) destination.is_a?(Integer) && ![1, 2].include?(destination) end
Determines if this class can handle the given destination
@param destination [Object] the destination to check
@return [Boolean] true if destination is a file descriptor that’s not stdout or stderr
Public Instance Methods
Source
# File lib/process_executer/destinations/file_descriptor.rb, line 23 def write(data) super io = ::IO.open(destination, mode: 'a', autoclose: false) io.write(data).tap { io.close } end
Writes data to the file descriptor
@param data [String] the data to write
@return [Integer] the number of bytes written
@raise [SystemCallError] if the file descriptor is invalid
@example
fd_handler = ProcessExecuter::Destinations::FileDescriptor.new(3) fd_handler.write("Hello world")
Calls superclass method
ProcessExecuter::Destinations::DestinationBase#write