Sha256: d127e5df7c421c32d5d83f2c7ea974bdeeeb02c93d2a7c58191a8c6ff4ab266d

Contents?: true

Size: 944 Bytes

Versions: 6

Compression:

Stored size: 944 Bytes

Contents

require 'psd/node'

class PSD
  module Node
    # Represents a group, or folder, in the PSD document. It can have
    # zero or more children nodes.
    class Group < PSD::Node::Base
      def passthru_blending?
        blending_mode == 'passthru'
      end

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

      # Export this layer and it's children to a hash recursively.
      def to_hash
        super.merge({
          type: :group,
          open: section_divider ? section_divider.layer_type == 'open folder' : false,
          children: children.map(&:to_hash)
        })
      end

      # If the method is missing, we blindly send it to the layer.
      # The layer handles the case in which the method doesn't exist.
      def method_missing(method, *args, &block)
        @layer.send(method, *args, &block)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
psd-3.9.0 lib/psd/nodes/group.rb
psd-3.8.0 lib/psd/nodes/group.rb
psd-3.7.0 lib/psd/nodes/group.rb
psd-3.6.0 lib/psd/nodes/group.rb
psd-3.5.0 lib/psd/nodes/group.rb
psd-3.4.0 lib/psd/nodes/group.rb