lib/psd/node_group.rb in psd-1.4.5 vs lib/psd/node_group.rb in psd-1.5.0

- old
+ new

@@ -44,10 +44,14 @@ # Attempt to show all children of this layer. def show! @children.each{ |c| c.show! } end + def empty? + @children.empty? + end + # Export this layer and it's children to a hash recursively. def to_hash super.merge({ type: :group, visible: visible?, @@ -62,12 +66,13 @@ end private def get_dimensions - @left = @children.map(&:left).min || 0 - @top = @children.map(&:top).min || 0 - @bottom = @children.map(&:bottom).max || 0 - @right = @children.map(&:right).max || 0 + children = @children.reject(&:empty?) + @left = children.map(&:left).min || 0 + @top = children.map(&:top).min || 0 + @bottom = children.map(&:bottom).max || 0 + @right = children.map(&:right).max || 0 end end end