Class: PSD::Resource::Section::Guides

Inherits:
PSD::Resource::Section show all
Defined in:
lib/psd/resources/guides.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PSD::Resource::Section

factory, #initialize

Constructor Details

This class inherits a constructor from PSD::Resource::Section

Class Method Details

.idObject



5
# File 'lib/psd/resources/guides.rb', line 5

def self.id; 1032; end

.nameObject



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

def self.name; :guides; end

Instance Method Details

#parseObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/psd/resources/guides.rb', line 8

def parse
  # Descriptor version
  @file.seek 4, IO::SEEK_CUR

  # Future implementation of document-specific grids
  @file.seek 8, IO::SEEK_CUR

  num_guides = @file.read_int

  @data = []

  num_guides.times do
    location = @file.read_int / 32
    direction = @file.read_byte == 0 ? "vertical" : "horizontal"

    @data.push({ :location => location, :direction => direction })
  end

  @resource.data = self
end

#to_aObject



29
30
31
# File 'lib/psd/resources/guides.rb', line 29

def to_a
  @data
end