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.

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:

  • destination (Object)

    the destination to write to

[View source]

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:

  • (Array<String>)

    the data written to the destination


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:

  • (Object)

    the destination object


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:

  • (Boolean)
[View source]

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:

  • destination (Object)

    the destination to check

Returns:

  • (Boolean)

    true if this class can handle the destination

Raises:

  • (NotImplementedError)

    if the subclass doesn't implement this method

[View source]

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.

[View source]

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:

  • (Boolean)
[View source]

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:

  • (String)
[View source]

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:

  • data (String)

    the data to write

Raises:

  • (NotImplementedError)

    if the subclass doesn't implement this method

[View source]

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

def write(data)
  @data_written << data
end