class Ahnnotate::Table
Attributes
columns[RW]
foreign_keys[RW]
indexes[RW]
name[RW]
Public Class Methods
new(**args)
click to toggle source
# File lib/ahnnotate/table.rb, line 8 def initialize(**args) args.each do |key, value| public_send("#{key}=", value) end end
Public Instance Methods
string(comment:)
click to toggle source
# File lib/ahnnotate/table.rb, line 14 def string(comment:) tabularizer = Function::Tabularize.new( prefix: "#{comment} ", cell_divider: " " ) output = StringIO.new output.puts "#{comment} == Schema Information" output.puts comment output.puts "#{comment} Table name: #{@name}" output.puts comment output.print tabularizer.call(columns, [:name, :type, :details]) output.puts comment if indexes.any? output.puts "#{comment} Indexes:" output.puts comment output.print tabularizer.call(indexes, [:name, :presentable_columns, :presentable_unique, :comment]) output.puts comment end if foreign_keys.any? output.puts "#{comment} Foreign keys:" output.puts comment output.puts tabularizer.call(foreign_keys, [:from, :to, :name]) output.puts comment end output.string end
Private Instance Methods
longest_column_name_length()
click to toggle source
# File lib/ahnnotate/table.rb, line 48 def longest_column_name_length @longest_column_name_length ||= @columns.map(&:name).map(&:size).max end