Class: DBF::VersionConfig
- Inherits:
-
Object
- Object
- DBF::VersionConfig
- Defined in:
- lib/dbf/version_config.rb
Constant Summary collapse
- DBASE2_HEADER_SIZE =
8- DBASE3_HEADER_SIZE =
32- DBASE7_HEADER_SIZE =
68- VERSIONS =
{ '02' => 'FoxBase', '03' => 'dBase III without memo file', '04' => 'dBase IV without memo file', '05' => 'dBase V without memo file', '07' => 'Visual Objects 1.x', '30' => 'Visual FoxPro', '32' => 'Visual FoxPro with field type Varchar or Varbinary', '31' => 'Visual FoxPro with AutoIncrement field', '43' => 'dBASE IV SQL table files, no memo', '63' => 'dBASE IV SQL system files, no memo', '7b' => 'dBase IV with memo file', '83' => 'dBase III with memo file', '87' => 'Visual Objects 1.x with memo file', '8b' => 'dBase IV with memo file', '8c' => 'dBase 7', '8e' => 'dBase IV with SQL table', 'cb' => 'dBASE IV SQL table files, with memo', 'f5' => 'FoxPro with memo file', 'fb' => 'FoxPro without memo file' }.freeze
- FOXPRO_VERSIONS =
{ '30' => 'Visual FoxPro', '31' => 'Visual FoxPro with AutoIncrement field', 'f5' => 'FoxPro with memo file', 'fb' => 'FoxPro without memo file' }.freeze
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #foxpro? ⇒ Boolean
- #header_size ⇒ Object
-
#initialize(version) ⇒ VersionConfig
constructor
A new instance of VersionConfig.
- #memo_class ⇒ Object
- #read_column_args(table, io) ⇒ Object
- #version_description ⇒ Object
Constructor Details
#initialize(version) ⇒ VersionConfig
Returns a new instance of VersionConfig.
40 41 42 |
# File 'lib/dbf/version_config.rb', line 40 def initialize(version) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
38 39 40 |
# File 'lib/dbf/version_config.rb', line 38 def version @version end |
Instance Method Details
#foxpro? ⇒ Boolean
59 60 61 |
# File 'lib/dbf/version_config.rb', line 59 def foxpro? FOXPRO_VERSIONS.key?(version) end |
#header_size ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dbf/version_config.rb', line 48 def header_size case version when '02' DBASE2_HEADER_SIZE when '04', '8c' DBASE7_HEADER_SIZE else DBASE3_HEADER_SIZE end end |
#memo_class ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/dbf/version_config.rb', line 63 def memo_class if foxpro? Memo::Foxpro else version == '83' ? Memo::Dbase3 : Memo::Dbase4 end end |
#read_column_args(table, io) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/dbf/version_config.rb', line 71 def read_column_args(table, io) case version when '02' then [table, *io.read(header_size * 2).unpack('A11 a C'), 0] when '04', '8c' then [table, *io.read(48).unpack('A32 a C C x13')] else [table, *io.read(header_size).unpack('A11 a x4 C2')] end end |
#version_description ⇒ Object
44 45 46 |
# File 'lib/dbf/version_config.rb', line 44 def version_description VERSIONS[version] end |