Class: ProcessExecuter::Destinations::IO Private

Inherits:
DestinationBase show all
Defined in:
lib/process_executer/destinations/io.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.

Handles IO objects

Instance Attribute Summary

Attributes inherited from DestinationBase

#destination

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DestinationBase

#close, compatible_with_monitored_pipe?, #compatible_with_monitored_pipe?, #initialize

Constructor Details

This class inherits a constructor from ProcessExecuter::Destinations::DestinationBase

Class Method Details

.handles?(destination) ⇒ Boolean

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.

Determines if this class can handle the given destination

Parameters:

  • destination (Object)

    the destination to check

Returns:

  • (Boolean)

    true if destination is an IO with a valid file descriptor



33
34
35
# File 'lib/process_executer/destinations/io.rb', line 33

def self.handles?(destination)
  destination.is_a?(::IO) && destination.respond_to?(:fileno) && destination.fileno
end

Instance Method Details

#write(data) ⇒ Integer

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.

Writes data to the IO object

Examples:

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

Parameters:

  • data (String)

    the data to write

Returns:

  • (Integer)

    the number of bytes written

Raises:

  • (IOError)

    if the IO object is closed



24
25
26
27
# File 'lib/process_executer/destinations/io.rb', line 24

def write(data)
  super
  destination.write data
end