Sha256: d7b143cb9abc0d598e53f4c90e4d15724f4fb65078b17df43a2003b288f3fbf5

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

module DBF
  module Memo
    class Base
      BLOCK_HEADER_SIZE = 8
      BLOCK_SIZE = 512

      def self.open(filename, version)
        self.new File.open(filename, 'rb'), version
      end

      def initialize(data, version)
        @data, @version = data, version
      end

      def get(start_block)
        if start_block > 0
          build_memo start_block
        end
      end

      def close
        @data.close && @data.closed?
      end

      def closed?
        @data.closed?
      end

      private

      def offset(start_block) #nodoc
        start_block * BLOCK_SIZE
      end

      def content_size(memo_size) #nodoc
        (memo_size - block_size) + BLOCK_HEADER_SIZE
      end

      def block_content_size #nodoc
        @block_content_size ||= block_size - BLOCK_HEADER_SIZE
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dbf-2.0.4 lib/dbf/memo/base.rb