Sha256: 9bc815cd6593b08f0d71280371eea0cf9b8ed8a600a242f555dd570d03fb165f

Contents?: true

Size: 816 Bytes

Versions: 4

Compression:

Stored size: 816 Bytes

Contents

class PSD
  # Parses and reads all of the Resource records in the document.
  class Resources
    include Section

    attr_reader :resources
    alias :data :resources
    
    def initialize(file)
      @file = file
      @resources = []
      @length = nil
    end

    # Parses each Resource and stores them.
    def parse
      start_section

      n = length
      start = @file.tell

      while n > 0
        pos = @file.tell
        @resources << PSD::Resource.read(@file)
        n -= @file.tell - pos
      end

      unless n == 0
        @file.seek start + length
      end

      end_section
      return @resources
    end

    def skip
      @file.seek length, IO::SEEK_CUR
    end

    private

    def length
      return @length unless @length.nil?
      @length = @file.read_int
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
psd-0.3.5 lib/psd/resources.rb
psd-0.3.4 lib/psd/resources.rb
psd-0.3.3 lib/psd/resources.rb
psd-0.3.2 lib/psd/resources.rb