class ProcessExecuter::Destinations::FilePathModePerms
@api private
Handles file paths with specific open modes and permissions
def self.handles?(destination)
-
(Boolean)
- true if destination is an Array with path, mode, and permissions
Parameters:
-
destination
(Object
) -- the destination to check
def self.handles?(destination) destination.is_a?(Array) && destination.size == 3 && destination[0].is_a?(String) && destination[1].is_a?(String) && destination[2].is_a?(Integer) end
def close
-
(void)
-
def close file.close unless file.closed? end
def initialize(destination)
-
(ArgumentError)
- if the mode is invalid -
(Errno::ENOENT)
- if the file path is invalid
Returns:
-
(FilePathModePerms)
- a new handler instance
Parameters:
-
destination
(Array
) -- array with file path, mode, and permissions
def initialize(destination) super @file = File.open(destination[0], destination[1], destination[2]) end
def write(data)
-
(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