Class: Innodb::DataType::CharacterType

Inherits:
Object
  • Object
show all
Defined in:
lib/innodb/data_type.rb

Overview

Fixed-length character type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_type, modifiers, properties) ⇒ CharacterType

Returns a new instance of CharacterType.



181
182
183
184
# File 'lib/innodb/data_type.rb', line 181

def initialize(base_type, modifiers, properties)
  @width = modifiers.fetch(0, 1)
  @name = Innodb::DataType.make_name(base_type, modifiers, properties)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



179
180
181
# File 'lib/innodb/data_type.rb', line 179

def name
  @name
end

#widthObject (readonly)

Returns the value of attribute width.



179
180
181
# File 'lib/innodb/data_type.rb', line 179

def width
  @width
end

Instance Method Details

#value(data) ⇒ Object



186
187
188
189
190
# File 'lib/innodb/data_type.rb', line 186

def value(data)
  # The SQL standard defines that CHAR fields should have end-spaces
  # stripped off.
  data.sub(/[ ]+$/, "")
end