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

Inherits:
Base
  • Object
show all
Defined in:
lib/psd/resources/guides.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, name, #name, #resource_id, resource_id

Constructor Details

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

Instance Method Details

#parseObject



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

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



31
32
33
# File 'lib/psd/resources/guides.rb', line 31

def to_a
  @data
end