class ProcessExecuter::Destinations::FilePathMode

@api private
Handles file paths with specific open modes

def self.handles?(destination)

Returns:
  • (Boolean) - true if destination is an Array with path and mode

Parameters:
  • destination (Object) -- the destination to check
def self.handles?(destination)
  destination.is_a?(Array) &&
    destination.size == 2 &&
    destination[0].is_a?(String) &&
    destination[1].is_a?(String)
end

def close

Returns:
  • (void) -
def close
  file.close unless file.closed?
end

def initialize(destination)

Raises:
  • (ArgumentError) - if the mode is invalid
  • (Errno::ENOENT) - if the file path is invalid

Returns:
  • (FilePathMode) - a new file path with mode destination handler

Parameters:
  • destination (Array) -- array with file path and mode
def initialize(destination)
  super
  @file = File.open(destination[0], destination[1], 0o644)
end

def write(data)

Raises:
  • (IOError) - if the file is closed

Returns:
  • (Integer) - the number of bytes written

Parameters:
  • data (String) -- the data to write
def write(data)
  super
  file.write data
end