Class: RailsAiBridge::Tools::SearchCode::Formatter
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::SearchCode::Formatter
- Defined in:
- lib/rails_ai_bridge/tools/search_code/formatter.rb
Overview
Formats the search results into a markdown string.
Instance Method Summary collapse
-
#call(results, pattern, path) ⇒ String
The formatted markdown output.
Instance Method Details
#call(results, pattern, path) ⇒ String
Returns The formatted markdown output.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails_ai_bridge/tools/search_code/formatter.rb', line 12 def call(results, pattern, path) if results.empty? return "No results found for '#{pattern}'#{" in #{path}" if path}." end output = results.map { |r| "#{r[:file]}:#{r[:line_number]}: #{r[:content].strip}" }.join("\n") header = "# Search: `#{pattern}` **#{results.size} results**#{" in #{path}" if path} ``` " = " ```" "#{header}#{output}#{}" end |