Class: PSD::Node::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/psd/nodes/group.rb

Overview

Represents a group, or folder, in the PSD document. It can have zero or more children nodes.

Constant Summary

Constants inherited from Base

Base::PROPERTIES

Instance Attribute Summary

Attributes inherited from Base

#children, #force_visible, #id, #layer, #left_offset, #name, #parent, #top_offset

Instance Method Summary collapse

Methods inherited from Base

#bottom, #clipping_mask, #color_label, #debug_name, #group?, #height, #hidden?, #initialize, #layer?, #left, #right, #top, #visible?, #width

Methods included from Locking

#all_locked?, #any_locked?, #composite_locked?, #position_locked?, #transparency_locked?

Methods included from BuildPreview

#renderer, #save_as_png, #to_png

Methods included from LayerComps

#filter_by_comp, #position_in_comp, #visible_in_comp?

Methods included from Search

#children_at_path, #find_by_id

Methods included from Ancestry

#ancestors, #childless?, #depth, #descendants, #has_children?, #has_siblings?, #next_sibling, #only_child?, #path, #prev_sibling, #root, #root?, #siblings, #subtree

Constructor Details

This class inherits a constructor from PSD::Node::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

If the method is missing, we blindly send it to the layer. The layer handles the case in which the method doesn’t exist.



31
32
33
# File 'lib/psd/nodes/group.rb', line 31

def method_missing(method, *args, &block)
  @layer.send(method, *args, &block)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
# File 'lib/psd/nodes/group.rb', line 12

def empty?
  children.each do |child|
    return false unless child.empty?
  end
  
  return true
end

#passthru_blending?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/psd/nodes/group.rb', line 8

def passthru_blending?
  blending_mode == 'passthru'
end

#to_hashObject

Export this layer and it’s children to a hash recursively.



21
22
23
24
25
26
27
# File 'lib/psd/nodes/group.rb', line 21

def to_hash
  super.merge({
    type: :group,
    open: section_divider ? section_divider.layer_type == 'open folder' : false,
    children: children.map(&:to_hash)
  })
end