Sha256: 0892df0c4d3fefa87986a5ecd572fe09713714b46a2aaf7230edb85eee72f7fd

Contents?: true

Size: 857 Bytes

Versions: 12

Compression:

Stored size: 857 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,
          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

12 entries across 12 versions & 1 rubygems

Version Path
psd-3.3.3 lib/psd/nodes/group.rb
psd-3.3.2 lib/psd/nodes/group.rb
psd-3.3.1 lib/psd/nodes/group.rb
psd-3.2.4 lib/psd/nodes/group.rb
psd-3.2.3 lib/psd/nodes/group.rb
psd-3.2.2 lib/psd/nodes/group.rb
psd-3.2.1 lib/psd/nodes/group.rb
psd-3.2.0 lib/psd/nodes/group.rb
psd-3.1.5 lib/psd/nodes/group.rb
psd-3.1.4 lib/psd/nodes/group.rb
psd-3.1.3 lib/psd/nodes/group.rb
psd-3.1.2 lib/psd/nodes/group.rb