Sha256: bbe84db76b7c01707b02e7e102d0042d07201d0a8074671b3cbd29c8e30d80ac

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 Bytes

Contents

module DBF
  module Memo
    class Foxpro < Base
      FPT_HEADER_SIZE = 512

      def build_memo(start_block) #nodoc
        @data.seek offset(start_block)

        memo_type, memo_size, memo_string = @data.read(block_size).unpack("NNa*")
        return nil unless memo_type == 1 && memo_size > 0

        if memo_size > block_content_size
          memo_string << @data.read(content_size(memo_size))
        else
          memo_string = memo_string[0, memo_size]
        end
        memo_string

      rescue
        nil
      end

      private

      def block_size #nodoc
        @block_size ||= begin
          @data.rewind
          @data.read(FPT_HEADER_SIZE).unpack('x6n').first || 0
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dbf-2.0.10 lib/dbf/memo/foxpro.rb
dbf-2.0.9 lib/dbf/memo/foxpro.rb
dbf-2.0.8 lib/dbf/memo/foxpro.rb
dbf-2.0.7 lib/dbf/memo/foxpro.rb
dbf-2.0.6 lib/dbf/memo/foxpro.rb