Class: DBF::ColumnType::AutoIncrement

Inherits:
Base
  • Object
show all
Defined in:
lib/dbf/column_type.rb

Instance Attribute Summary

Attributes inherited from Base

#decimal, #encoding

Instance Method Summary collapse

Methods inherited from Base

#blank_value, #decode, #initialize, #skip_blank?

Constructor Details

This class inherits a constructor from DBF::ColumnType::Base

Instance Method Details

#type_cast(value) ⇒ Object

Parameters:



70
71
72
73
74
75
76
# File 'lib/dbf/column_type.rb', line 70

def type_cast(value)
  bits = value.unpack1('B*')
  return nil unless bits && bits.length >= 32

  sign_multiplier = bits[0] == '0' ? -1 : 1
  bits[1, 31].to_i(2) * sign_multiplier
end