Class: Girb::Tools::GetSource
- Inherits:
-
Base
- Object
- Base
- Girb::Tools::GetSource
show all
- Defined in:
- lib/girb/tools/get_source.rb
Constant Summary
collapse
- MAX_SOURCE_LINES =
50
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
available?, to_gemini_tool, tool_name
Class Method Details
.description ⇒ Object
12
13
14
|
# File 'lib/girb/tools/get_source.rb', line 12
def description
"Get the source code of a method or class definition. Use 'Class#method' for instance methods, 'Class.method' for class methods."
end
|
.parameters ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/girb/tools/get_source.rb', line 16
def parameters
{
type: "object",
properties: {
target: {
type: "string",
description: "Class or method to get source for (e.g., 'User', 'User#save', 'User.find')"
}
},
required: ["target"]
}
end
|
Instance Method Details
#execute(binding, target:) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/girb/tools/get_source.rb', line 30
def execute(binding, target:)
if target.include?("#")
get_instance_method_source(binding, target)
elsif target.include?(".")
get_class_method_source(binding, target)
else
get_class_info(binding, target)
end
rescue NameError => e
{ error: "Not found: #{e.message}" }
rescue StandardError => e
{ error: "#{e.class}: #{e.message}" }
end
|