Class: LLM::Tool::WriteFile
- Defined in:
- lib/llm/tools/write_file.rb
Overview
The LLM::Tool::WriteFile class implements a tool that can write a given string to a given file path.
Instance Method Summary collapse
Methods inherited from LLM::Tool
NotFound, a2a, a2a?, #a2a?, abstract!, abstract?, clear_registry!, description, find_by_name!, #function, function, inherited, mcp, #mcp?, mcp?, name, #on_cancel, #on_interrupt, params, register, registry, set, subclasses, unregister
Methods included from Param
Methods included from Function::Registry
#clear_registry!, #find_by_name, #lock, #register, #registry, #registry_key, #tool_name, #unregister
Instance Method Details
#call(path:, content:, newline: true) ⇒ Hash
21 22 23 24 25 |
# File 'lib/llm/tools/write_file.rb', line 21 def call(path:, content:, newline: true) content = content.end_with?("\n") ? content : "#{content}\n" if newline File.open(path, "w") { _1.write(content) } {ok: true} end |