Class: RailsAiBridge::Tools::Schema::SummaryFormatter
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::Schema::SummaryFormatter
- Defined in:
- lib/rails_ai_bridge/tools/schema/summary_formatter.rb
Overview
Renders a compact summary of all tables: name + column/index counts.
Instance Method Summary collapse
-
#call ⇒ String
Markdown summary listing.
- #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/summary_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 summary listing.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_ai_bridge/tools/schema/summary_formatter.rb', line 22 def call paginated = @tables.keys.sort.drop(@offset).first(@limit) lines = ["# Schema Summary (#{@total} tables)", ''] paginated.each do |name| data = @tables[name] col_count = data[:columns]&.size || 0 idx_count = data[:indexes]&.size || 0 lines << "- **#{name}** — #{col_count} columns, #{idx_count} indexes" end if @offset + @limit < @total lines << '' << "_Showing #{paginated.size} of #{@total}. " \ "Use `offset:#{@offset + @limit}` for more, or `table:\"name\"` for full detail._" end lines.join("\n") end |