Class: ProcessExecuter::DestinationBase Private

Inherits:
Object
  • Object
show all
Defined in:
lib/process_executer/destination_base.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.

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destination) ⇒ DestinationBase

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.

Initializes a new destination handler

Parameters:

  • the destination to write to

API:

  • private



15
16
17
18
# File 'lib/process_executer/destination_base.rb', line 15

def initialize(destination)
  @destination = destination
  @data_written = []
end

Instance Attribute Details

#data_writtenArray<String> (readonly)

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.

The data written to the destination

Returns:

  • the data written to the destination

API:

  • private



28
29
30
# File 'lib/process_executer/destination_base.rb', line 28

def data_written
  @data_written
end

#destinationObject (readonly)

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.

The destination object this handler manages

Returns:

  • the destination object

API:

  • private



23
24
25
# File 'lib/process_executer/destination_base.rb', line 23

def destination
  @destination
end

Class Method Details

.compatible_with_monitored_pipe?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 destination class can be wrapped by MonitoredPipe

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

Returns:

API:

  • private



73
# File 'lib/process_executer/destination_base.rb', line 73

def self.compatible_with_monitored_pipe? = true

.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

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

Parameters:

  • the destination to check

Returns:

  • true if this class can handle the destination

Raises:

  • if the subclass doesn't implement this method

API:

  • private



62
63
64
# File 'lib/process_executer/destination_base.rb', line 62

def self.handles?(destination)
  raise NotImplementedError
end

Instance Method Details

#close

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.

This method returns an undefined value.

Closes the destination if necessary

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

API:

  • private



53
# File 'lib/process_executer/destination_base.rb', line 53

def close; end

#compatible_with_monitored_pipe?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 destination instance can be wrapped by MonitoredPipe

Returns:

API:

  • private



79
80
81
# File 'lib/process_executer/destination_base.rb', line 79

def compatible_with_monitored_pipe?
  self.class.compatible_with_monitored_pipe?
end

#stringString

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.

The data written to the destination as a single string

Returns:

API:

  • private



32
33
34
# File 'lib/process_executer/destination_base.rb', line 32

def string
  data_written.join
end

#write(data)

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.

This method returns an undefined value.

Writes data to the destination

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

Parameters:

  • the data to write

Raises:

  • if the subclass doesn't implement this method

API:

  • private



43
44
45
# File 'lib/process_executer/destination_base.rb', line 43

def write(data)
  @data_written << data
end