Class: MontyAI::FileHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/monty_ai/file_handler.rb

Overview

Class FileHandler opens files for explanations

Class Method Summary collapse

Class Method Details

.read(path) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/monty_ai/file_handler.rb', line 6

def self.read(path)
  raise Error, "File not found: #{path}" unless File.exist?(path)

  raise Error, "Cannot read file: #{path}" unless File.readable?(path)

  File.read(path)
rescue StandardError => e
  raise Error, "Failed to read file: #{e.message}"
end