Class: MysqlInspector::Column

Inherits:
Struct
  • Object
show all
Includes:
TablePart
Defined in:
lib/mysql_inspector/column.rb

Instance Attribute Summary collapse

Attributes included from TablePart

#table

Instance Method Summary collapse

Methods included from TablePart

#<=>

Instance Attribute Details

#auto_incrementObject

Returns the value of attribute auto_increment

Returns:

  • (Object)

    the current value of auto_increment



2
3
4
# File 'lib/mysql_inspector/column.rb', line 2

def auto_increment
  @auto_increment
end

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



2
3
4
# File 'lib/mysql_inspector/column.rb', line 2

def default
  @default
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/mysql_inspector/column.rb', line 2

def name
  @name
end

#nullableObject

Returns the value of attribute nullable

Returns:

  • (Object)

    the current value of nullable



2
3
4
# File 'lib/mysql_inspector/column.rb', line 2

def nullable
  @nullable
end

#sql_typeObject

Returns the value of attribute sql_type

Returns:

  • (Object)

    the current value of sql_type



2
3
4
# File 'lib/mysql_inspector/column.rb', line 2

def sql_type
  @sql_type
end

Instance Method Details

#=~(matcher) ⇒ Object



16
17
18
# File 'lib/mysql_inspector/column.rb', line 16

def =~(matcher)
  name =~ matcher
end

#to_sqlObject



6
7
8
9
10
11
12
13
14
# File 'lib/mysql_inspector/column.rb', line 6

def to_sql
  parts = []
  parts << quote(name)
  parts << sql_type
  parts << (nullable ? "NULL" : "NOT NULL")
  parts << "DEFAULT #{default}" if default
  parts << "AUTO_INCREMENT" if auto_increment
  parts * " "
end