class Innodb::DataType::IntegerType

Attributes

name[R]
width[R]

Public Class Methods

new(base_type, modifiers, properties) click to toggle source
# File lib/innodb/data_type.rb, line 31
def initialize(base_type, modifiers, properties)
  @width = base_type_width_map[base_type]
  @unsigned = properties.include?(:UNSIGNED)
  @name = Innodb::DataType.make_name(base_type, modifiers, properties)
end

Public Instance Methods

base_type_width_map() click to toggle source
# File lib/innodb/data_type.rb, line 37
def base_type_width_map
  {
    BOOL: 1,
    BOOLEAN: 1,
    TINYINT: 1,
    SMALLINT: 2,
    MEDIUMINT: 3,
    INT: 4,
    INT6: 6,
    BIGINT: 8,
  }
end
get_int(data, nbits) click to toggle source
# File lib/innodb/data_type.rb, line 59
def get_int(data, nbits)
  BinData.const_get("Int%dbe" % nbits).read(data) ^ (-1 << (nbits - 1))
end
get_uint(data, nbits) click to toggle source
# File lib/innodb/data_type.rb, line 55
def get_uint(data, nbits)
  BinData.const_get("Uint%dbe" % nbits).read(data)
end
value(data) click to toggle source
# File lib/innodb/data_type.rb, line 50
def value(data)
  nbits = @width * 8
  @unsigned ? get_uint(data, nbits) : get_int(data, nbits)
end