class ProcessExecuter::Destinations::DestinationBase

Base class for all destination handlers

Provides the common interface and functionality for all destination classes that handle different types of output redirection.

@api private

Attributes

destination[R]

The destination object this handler manages

@return [Object] the destination object

Public Class Methods

compatible_with_monitored_pipe?(= true) click to toggle source

Determines if this destination class can be wrapped by MonitoredPipe

All destination types can be wrapped by MonitoredPipe unless they explicitly opt out.

@return [Boolean]

# File lib/process_executer/destinations/destination_base.rb, line 63
  def self.compatible_with_monitored_pipe? = true

  # Determines if this destination instance can be wrapped by MonitoredPipe
  #
  # @return [Boolean]
  def compatible_with_monitored_pipe?
    self.class.compatible_with_monitored_pipe?
  end
end
handles?(destination) click to toggle source

Determines if this class can handle the given destination

This is an abstract class method that must be implemented by subclasses.

@param destination [Object] the destination to check @return [Boolean] true if this class can handle the destination @raise [NotImplementedError] if the subclass doesn’t implement this method

# File lib/process_executer/destinations/destination_base.rb, line 53
def self.handles?(destination)
  raise NotImplementedError
end
new(destination) click to toggle source

Initializes a new destination handler

@param destination [Object] the destination to write to

# File lib/process_executer/destinations/destination_base.rb, line 16
def initialize(destination)
  @destination = destination
end

Public Instance Methods

close() click to toggle source

Closes the destination if necessary

By default, this method does nothing. Subclasses should override this method if they need to perform cleanup.

@return [void]

# File lib/process_executer/destinations/destination_base.rb, line 44
def close; end
compatible_with_monitored_pipe?() click to toggle source

Determines if this destination instance can be wrapped by MonitoredPipe

@return [Boolean]

# File lib/process_executer/destinations/destination_base.rb, line 68
def compatible_with_monitored_pipe?
  self.class.compatible_with_monitored_pipe?
end
write(_data) click to toggle source

Writes data to the destination

Subclasses should override this method to provide specific write behavior. The base implementation is a no-op.

@param _data [String] the data to write

@return [Integer] the number of bytes written

# File lib/process_executer/destinations/destination_base.rb, line 34
def write(_data)
  0
end