Method: PSD::Resources#parse

Defined in:
lib/psd/resources.rb

#parseObject

Parses each Resource and stores them.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/psd/resources.rb', line 17

def parse
  start_section

  n = length
  start = @file.tell

  while n > 0
    pos = @file.tell

    resource = Resource.new(@file)
    resource.parse

    resource_end = @file.tell + resource.size

    name = Resource::Section.factory(@file, resource)
    @resources[resource.id] = resource
    @type_index[name] = resource.id unless name.nil?

    @file.seek resource_end
    n -= @file.tell - pos
  end

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

  end_section
end