Class: PSD::Resources

Inherits:
Object
  • Object
show all
Includes:
Section
Defined in:
lib/psd/resources.rb

Overview

Parses and reads all of the Resource records in the document.

Instance Attribute Summary collapse

Attributes included from Section

#section_end, #section_start

Instance Method Summary collapse

Methods included from Section

#end_of_section, #end_section, #start_of_section, #start_section

Constructor Details

#initialize(file) ⇒ Resources

Returns a new instance of Resources.



9
10
11
12
13
# File 'lib/psd/resources.rb', line 9

def initialize(file)
  @file = file
  @resources = []
  @length = nil
end

Instance Attribute Details

#resourcesObject (readonly) Also known as: data

Returns the value of attribute resources.



6
7
8
# File 'lib/psd/resources.rb', line 6

def resources
  @resources
end

Instance Method Details

#parseObject

Parses each Resource and stores them.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/psd/resources.rb', line 16

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

#skipObject



36
37
38
# File 'lib/psd/resources.rb', line 36

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