Sha256: 674abacf304c67b960bab69d04c91d66305f673cd4f63ab041967400573e551d

Contents?: true

Size: 512 Bytes

Versions: 6

Compression:

Stored size: 512 Bytes

Contents

# frozen_string_literal: true

require 'image_size/chunky_reader'

class ImageSize
  class SeekableIOReader # :nodoc:
    include ChunkyReader

    def initialize(io)
      @io = io
      @pos = 0
      @chunks = {}
    end

  private

    def chunk(i)
      unless @chunks.key?(i)
        @io.seek((chunk_size * i) - @pos, IO::SEEK_CUR)
        data = @io.read(chunk_size)
        @pos = chunk_size * i
        @pos += data.length if data
        @chunks[i] = data
      end

      @chunks[i]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
image_size-3.4.0 lib/image_size/seekable_io_reader.rb
image_size-3.3.0 lib/image_size/seekable_io_reader.rb
image_size-3.2.0 lib/image_size/seekable_io_reader.rb
image_size-3.1.0 lib/image_size/seekable_io_reader.rb
image_size-3.0.2 lib/image_size/seekable_io_reader.rb
image_size-3.0.1 lib/image_size/seekable_io_reader.rb