Module: DeepL::Utils::OutputPath Private

Extended by:
OutputPath
Included in:
OutputPath
Defined in:
lib/deepl/utils/output_path.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Checks of an output file path before any request is sent.

Instance Method Summary collapse

Instance Method Details

#check!(path) ⇒ 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.

Raises:

  • (Errno::EEXIST) —

    If path exists.

  • (Errno::ENOENT) —

    If the directory of path does not exist.

  • (Errno::EACCES) —

    If the directory of path is not writable.



16
17
18
19
20
21
22
# File 'lib/deepl/utils/output_path.rb', line 16

def check!(path)
  raise Errno::EEXIST, path.to_s if File.exist?(path)

  directory = File.dirname(path)
  raise Errno::ENOENT, directory unless File.directory?(directory)
  raise Errno::EACCES, directory unless File.writable?(directory)
end