Sha256: 8ef35050132022fd17452be9173abac2b08047b38c05f6ee8976a40b46a09ddd
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Ahnnotate class Table attr_accessor :name attr_accessor :columns attr_accessor :indexes def initialize(**args) args.each do |key, value| public_send("#{key}=", value) end end def string(comment:) tabularizer = Function::Tabularize.new( prefix: "#{comment} ", cell_divider: " " ) output = StringIO.new output.puts "#{comment} == Schema Info" 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 output.string end private def longest_column_name_length @longest_column_name_length ||= @columns.map(&:name).map(&:size).max end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ahnnotate-0.2.0 | lib/ahnnotate/table.rb |