Class: Asimov::Utils::FileManager

Inherits:
Object
  • Object
show all
Defined in:
lib/asimov/utils/file_manager.rb

Overview

File-related utility methods.

Not intended for client use.

Class Method Summary collapse

Class Method Details

.open(file_or_path) ⇒ Object

Returns the file corresponding to the file_or_path. If the argument is a file, then just returns the argument. Otherwise calls File.open with the argument. Raises an error if the file cannot be opened.

Parameters:

  • file_or_path (File/String)

    the path to the file to be opened



18
19
20
21
22
# File 'lib/asimov/utils/file_manager.rb', line 18

def self.open(file_or_path)
  file?(file_or_path) ? file_or_path : File.open(file_or_path)
rescue SystemCallError => e
  raise Asimov::FileCannotBeOpenedError.new(file_or_path, e.message)
end