Class: RailsAiBridge::Tools::Schema::StandardFormatter
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::Schema::StandardFormatter
- Defined in:
- lib/rails_ai_bridge/tools/schema/standard_formatter.rb
Overview
Renders tables with column names and types (no indexes or foreign keys).
Instance Method Summary collapse
-
#call ⇒ String
Markdown listing with column signatures.
- #initialize(tables:, total:, limit:, offset:) ⇒ void constructor
Constructor Details
#initialize(tables:, total:, limit:, offset:) ⇒ void
14 15 16 17 18 19 |
# File 'lib/rails_ai_bridge/tools/schema/standard_formatter.rb', line 14 def initialize(tables:, total:, limit:, offset:) @tables = tables @total = total @limit = limit @offset = offset end |
Instance Method Details
#call ⇒ String
Returns Markdown listing with column signatures.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_ai_bridge/tools/schema/standard_formatter.rb', line 22 def call paginated = @tables.keys.sort.drop(@offset).first(@limit) lines = ["# Schema (#{@total} tables, showing #{paginated.size})", ''] paginated.each do |name| data = @tables[name] cols = (data[:columns] || []).map { |c| "#{c[:name]}:#{c[:type]}" }.join(', ') lines << "### #{name}" lines << cols lines << '' end if @offset + @limit < @total lines << "_Use `detail:\"summary\"` for all #{@total} tables, " \ '`detail:"full"` for indexes/FKs, or `table:"name"` for one table._' end lines.join("\n") end |