Class: PSD::Node::Layer
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
Attributes inherited from Base
#children, #force_visible, #left_offset, #name, #parent, #top_offset
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#method_missing(method, *args, &block) ⇒ Object
If the method is missing, we blindly send it to the layer.
-
#to_hash ⇒ Object
Exports this layer to a Hash.
Methods inherited from Base
#bottom, #clipping_mask, #debug_name, #group?, #height, #hidden?, #initialize, #layer?, #left, #right, #top, #visible?, #width
Methods included from BuildPreview
#renderer, #save_as_png, #to_png
Methods included from Search
#children_at_path, #filter_by_comp
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.
35 36 37 |
# File 'lib/psd/nodes/layer.rb', line 35 def method_missing(method, *args, &block) @layer.send(method, *args, &block) end |
Instance Attribute Details
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
6 7 8 |
# File 'lib/psd/nodes/layer.rb', line 6 def layer @layer end |
Instance Method Details
#empty? ⇒ Boolean
13 14 15 |
# File 'lib/psd/nodes/layer.rb', line 13 def empty? width == 0 || height == 0 end |
#to_hash ⇒ Object
Exports this layer to a Hash.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/psd/nodes/layer.rb', line 18 def to_hash super.merge({ type: :layer, text: @layer.text, ref_x: @layer.reference_point.x, ref_y: @layer.reference_point.y, mask: @layer.mask.to_hash, image: { width: @layer.image.width, height: @layer.image.height, channels: @layer.channels_info } }) end |