Class: PSD::Resource::Section::Slices

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

Instance Attribute Summary collapse

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 Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/psd/resources/slices.rb', line 12

def parse
  @version = @file.read_int

  case @version
  when 6 then parse_legacy
  when 7, 8 then
    descriptor_version = @file.read_int
    @data = Descriptor.new(@file).parse
  end

  normalize_data!

  @resource.data = self
end

#to_aObject



27
28
29
30
# File 'lib/psd/resources/slices.rb', line 27

def to_a
  return [] if @data.nil?
  @data[:slices]
end