Class: DeepAgents::FileSystem
- Inherits:
-
Object
- Object
- DeepAgents::FileSystem
- Defined in:
- lib/deepagents/tools.rb
Overview
FileSystem class for managing virtual files
Instance Method Summary collapse
- #delete(path) ⇒ Object
- #exists?(path) ⇒ Boolean
-
#initialize(initial_files = {}) ⇒ FileSystem
constructor
A new instance of FileSystem.
- #list ⇒ Object
- #read(path) ⇒ Object
- #to_h ⇒ Object
- #write(path, content) ⇒ Object
Constructor Details
#initialize(initial_files = {}) ⇒ FileSystem
68 69 70 |
# File 'lib/deepagents/tools.rb', line 68 def initialize(initial_files = {}) @files = initial_files end |
Instance Method Details
#delete(path) ⇒ Object
82 83 84 85 |
# File 'lib/deepagents/tools.rb', line 82 def delete(path) raise FileNotFoundError.new(path) unless @files.key?(path) @files.delete(path) end |
#exists?(path) ⇒ Boolean
91 92 93 |
# File 'lib/deepagents/tools.rb', line 91 def exists?(path) @files.key?(path) end |
#list ⇒ Object
87 88 89 |
# File 'lib/deepagents/tools.rb', line 87 def list @files.keys end |
#read(path) ⇒ Object
72 73 74 75 76 |
# File 'lib/deepagents/tools.rb', line 72 def read(path) file = @files[path] raise FileNotFoundError.new(path) unless file file end |
#to_h ⇒ Object
95 96 97 |
# File 'lib/deepagents/tools.rb', line 95 def to_h @files end |
#write(path, content) ⇒ Object
78 79 80 |
# File 'lib/deepagents/tools.rb', line 78 def write(path, content) @files[path] = content end |