Sha256: 555399f31269b795f1996b62b95b9e5c6b72291157faaff3d3cdab3f74022dbc

Contents?: true

Size: 581 Bytes

Versions: 4

Compression:

Stored size: 581 Bytes

Contents

module DBF
  class Header
    attr_reader :version, :record_count, :header_length, :record_length, :encoding_key, :encoding

    def initialize(data)
      @data = data
      unpack_header
    end

    def unpack_header
      @version = @data.unpack1('H2')

      case @version
      when '02'
        @record_count, @record_length = @data.unpack('x v x3 v')
        @header_length = 521
      else
        @record_count, @header_length, @record_length, @encoding_key = @data.unpack('x x3 V v2 x17 H2')
        @encoding = DBF::ENCODINGS[@encoding_key]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dbf-5.0.1 lib/dbf/header.rb
dbf-5.0.0 lib/dbf/header.rb
dbf-4.3.2 lib/dbf/header.rb
dbf-4.3.1 lib/dbf/header.rb