Class: PSD::LayerSectionDivider

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

Constant Summary collapse

SECTION_DIVIDER_TYPES =
[
  "other",
  "open folder",
  "closed folder",
  "bounding section divider"
]

Instance Attribute Summary collapse

Attributes inherited from LayerInfo

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LayerInfo

#skip

Constructor Details

#initialize(file, length) ⇒ LayerSectionDivider

Returns a new instance of LayerSectionDivider.



18
19
20
21
22
23
24
25
# File 'lib/psd/layer/info/layer_section_divider.rb', line 18

def initialize(file, length)
  super

  @is_folder = false
  @is_hidden = false
  @blend_mode = nil
  @sub_type = nil
end

Instance Attribute Details

#blend_modeObject (readonly)

Returns the value of attribute blend_mode.



9
10
11
# File 'lib/psd/layer/info/layer_section_divider.rb', line 9

def blend_mode
  @blend_mode
end

#is_folderObject (readonly)

Returns the value of attribute is_folder.



9
10
11
# File 'lib/psd/layer/info/layer_section_divider.rb', line 9

def is_folder
  @is_folder
end

#is_hiddenObject (readonly)

Returns the value of attribute is_hidden.



9
10
11
# File 'lib/psd/layer/info/layer_section_divider.rb', line 9

def is_hidden
  @is_hidden
end

#layer_typeObject (readonly)

Returns the value of attribute layer_type.



9
10
11
# File 'lib/psd/layer/info/layer_section_divider.rb', line 9

def layer_type
  @layer_type
end

#sub_typeObject (readonly)

Returns the value of attribute sub_type.



9
10
11
# File 'lib/psd/layer/info/layer_section_divider.rb', line 9

def sub_type
  @sub_type
end

Class Method Details

.should_parse?(key) ⇒ Boolean

Returns:

  • (Boolean)


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

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

Instance Method Details

#parseObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/psd/layer/info/layer_section_divider.rb', line 27

def parse
  code = @file.read_int
  @layer_type = SECTION_DIVIDER_TYPES[code]

  case code
  when 1, 2 then @is_folder = true
  when 3 then @is_hidden = true
  end

  PSD.logger.warn "Section divider is unexpected value: #{code}" if code > 4

  return self unless @length >= 12

  @file.seek 4, IO::SEEK_CUR # sig
  @blend_mode = @file.read_string(4)

  return self unless @length >= 16

  @sub_type = @file.read_int == 0 ? 'normal' : 'scene group'

  return self
end