Class: PSD::MetadataSetting

Inherits:
LayerInfo show all
Defined in:
lib/psd/layer/info/metadata_setting.rb

Instance Attribute Summary

Attributes inherited from LayerInfo

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LayerInfo

#initialize, #skip

Constructor Details

This class inherits a constructor from PSD::LayerInfo

Class Method Details

.should_parse?(key) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/psd/layer/info/metadata_setting.rb', line 5

def self.should_parse?(key)
  key == 'shmd'
end

Instance Method Details

#parseObject



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

def parse
  count = @file.read_int

  count.times do
    @file.seek 4, IO::SEEK_CUR # signature, always 8BIM
    
    key = @file.read_string(4)
    copy_on_sheet_dup = @file.read(1).bytes.to_a[0]
    @file.seek 3, IO::SEEK_CUR # Padding

    len = @file.read_int
    data_end = @file.tell + len

    PSD.logger.debug "Layer metadata: key = #{key}, length = #{len}"

    parse_layer_comp_setting if key == 'cmls'

    @file.seek data_end
  end
end