Class: ProcessExecuter::Destinations::Writer Private

Inherits:
ProcessExecuter::DestinationBase show all
Defined in:
lib/process_executer/destinations/writer.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 generic objects that respond to write

Instance Attribute Summary

Attributes inherited from ProcessExecuter::DestinationBase

#data_written, #destination

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ProcessExecuter::DestinationBase

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

Constructor Details

This class inherits a constructor from ProcessExecuter::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 responds to write but is not an IO with fileno



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

def self.handles?(destination)
  destination.respond_to?(:write) && (!destination.respond_to?(:fileno) || destination.fileno.nil?)
end

Instance Method Details

#write(data) ⇒ Object

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 destination object

Examples:

buffer = StringIO.new
writer_handler = ProcessExecuter::Destinations::Writer.new(buffer)
writer_handler.write("Hello world")

Parameters:

  • data (String)

    the data to write

Returns:

  • (Object)

    the return value of the destination's write method

Raises:

  • (NoMethodError)

    if the destination doesn't respond to write



19
20
21
22
# File 'lib/process_executer/destinations/writer.rb', line 19

def write(data)
  super
  destination.write data
end