Module: PSD::Layer::Helpers

Included in:
PSD::Layer
Defined in:
lib/psd/layer/helpers.rb

Instance Method Summary collapse

Instance Method Details

#all_locked?Boolean

Is the layer completely locked?

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/psd/layer/helpers.rb', line 27

def all_locked?
  return false unless info.has_key?(:locked)
  info[:locked].all_locked
end

#composite_locked?Boolean

Is the layer composite locked?

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/psd/layer/helpers.rb', line 39

def composite_locked?
  return false unless info.has_key?(:locked)
  info[:locked].composite_locked
end

#fill_opacityObject



61
62
63
64
# File 'lib/psd/layer/helpers.rb', line 61

def fill_opacity
  return 255 unless info.has_key?(:fill_opacity)
  info[:fill_opacity].value
end

#folder?Boolean

Does this layer represent the start of a folder section?

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'lib/psd/layer/helpers.rb', line 5

def folder?
  if info.has_key?(:section_divider)
    info[:section_divider].is_folder
  elsif info.has_key?(:nested_section_divider)
    info[:nested_section_divider].is_folder
  else
    name == "<Layer group>"
  end
end

#folder_end?Boolean

Does this layer represent the end of a folder section?

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'lib/psd/layer/helpers.rb', line 16

def folder_end?
  if info.has_key?(:section_divider)
    info[:section_divider].is_hidden
  elsif info.has_key?(:nested_section_divider)
    info[:nested_section_divider].is_hidden
  else
    name == "</Layer group>"
  end
end

#layer_typeObject



56
57
58
59
# File 'lib/psd/layer/helpers.rb', line 56

def layer_type
  return 'normal' unless info.has_key?(:section_divider)
  info[:section_divider].layer_type
end

#position_locked?Boolean

Is the layer position locked?

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/psd/layer/helpers.rb', line 33

def position_locked?
  return false unless info.has_key?(:locked)
  info[:locked].position_locked
end

#raster_mask?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/psd/layer/helpers.rb', line 66

def raster_mask?
  image.has_mask? && image.mask_data.length > 0
end

#textObject

Helper that exports the text data in this layer, if any.



51
52
53
54
# File 'lib/psd/layer/helpers.rb', line 51

def text
  return nil unless info[:type]
  info[:type].to_hash
end

#transparency_locked?Boolean

Is the layer transparency locked?

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/psd/layer/helpers.rb', line 45

def transparency_locked?
  return false unless info.has_key?(:locked)
  info[:locked].transparency_locked
end

#vector_mask?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/psd/layer/helpers.rb', line 70

def vector_mask?
  !vector_mask.nil?
end