Class: SchemaPlus::Core::SchemaDump::Table::Column

Inherits:
Struct
  • Object
show all
Defined in:
lib/schema_plus/core/schema_dump.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentsObject

Returns the value of attribute comments

Returns:

  • the current value of comments



91
92
93
# File 'lib/schema_plus/core/schema_dump.rb', line 91

def comments
  @comments
end

#nameObject

Returns the value of attribute name

Returns:

  • the current value of name



91
92
93
# File 'lib/schema_plus/core/schema_dump.rb', line 91

def name
  @name
end

#optionsObject

Returns the value of attribute options

Returns:

  • the current value of options



91
92
93
# File 'lib/schema_plus/core/schema_dump.rb', line 91

def options
  @options
end

#typeObject

Returns the value of attribute type

Returns:

  • the current value of type



91
92
93
# File 'lib/schema_plus/core/schema_dump.rb', line 91

def type
  @type
end

Instance Method Details

#assemble(stream, typelen, namelen) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/schema_plus/core/schema_dump.rb', line 93

def assemble(stream, typelen, namelen)
  stream.write "t.%-#{typelen}s " % type
  if options.blank? && comments.blank?
    stream.write name.inspect
  else
    pr = name.inspect
    pr += ',' unless options.blank?
    stream.write "%-#{namelen+3}s " % pr
  end
  stream.write options.to_s.sub(/^{(.*)}$/, '\1') unless options.blank?
  stream.write ' ' unless options.blank? or comments.blank?
  stream.write '# ' + comments.join('; ') unless comments.blank?
end