Class: PSD::Node
- Inherits:
-
Object
- Object
- PSD::Node
- Includes:
- Ancestry, BuildPreview, ParseLayers, Search
- Defined in:
- lib/psd/node.rb,
lib/psd/node_root.rb,
lib/psd/node_group.rb,
lib/psd/node_layer.rb,
lib/psd/nodes/search.rb,
lib/psd/nodes/ancestry.rb,
lib/psd/nodes/parse_layers.rb,
lib/psd/nodes/build_preview.rb,
lib/psd/nodes/lock_to_origin.rb
Defined Under Namespace
Modules: Ancestry, BuildPreview, LockToOrigin, ParseLayers, Search Classes: Group, Layer, Root
Constant Summary collapse
- PROPERTIES =
Default properties that all nodes contain
[:name, :left, :right, :top, :bottom, :height, :width]
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#force_visible ⇒ Object
Returns the value of attribute force_visible.
-
#layer ⇒ Object
Returns the value of attribute layer.
-
#left ⇒ Object
Returns the value of attribute left.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#top ⇒ Object
Returns the value of attribute top.
Instance Method Summary collapse
- #debug_name ⇒ Object
- #document_dimensions ⇒ Object
- #group? ⇒ Boolean
- #hidden? ⇒ Boolean
-
#initialize(layers = []) ⇒ Node
constructor
A new instance of Node.
- #layer? ⇒ Boolean
- #psd ⇒ Object
- #to_hash ⇒ Object
- #visible? ⇒ Boolean
Methods included from BuildPreview
#renderer, #save_as_png, #to_png
Methods included from Search
#children_at_path, #filter_by_comp
Methods included from Ancestry
#ancestors, #childless?, #depth, #descendants, #has_children?, #has_siblings?, #method_missing, #next_sibling, #only_child?, #path, #prev_sibling, #root, #root?, #siblings, #subtree
Methods included from ParseLayers
Constructor Details
#initialize(layers = []) ⇒ Node
Returns a new instance of Node.
18 19 20 21 22 23 24 |
# File 'lib/psd/node.rb', line 18 def initialize(layers=[]) parse_layers(layers) @force_visible = nil @top = @layer.top @left = @layer.left end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PSD::Node::Ancestry
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def children @children end |
#force_visible ⇒ Object
Returns the value of attribute force_visible.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def force_visible @force_visible end |
#layer ⇒ Object
Returns the value of attribute layer.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def layer @layer end |
#left ⇒ Object
Returns the value of attribute left.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def left @left end |
#parent ⇒ Object
Returns the value of attribute parent.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def parent @parent end |
#top ⇒ Object
Returns the value of attribute top.
16 17 18 |
# File 'lib/psd/node.rb', line 16 def top @top end |
Instance Method Details
#debug_name ⇒ Object
47 48 49 |
# File 'lib/psd/node.rb', line 47 def debug_name root? ? ":root:" : name end |
#document_dimensions ⇒ Object
66 67 68 |
# File 'lib/psd/node.rb', line 66 def document_dimensions @parent.document_dimensions end |
#group? ⇒ Boolean
43 44 45 |
# File 'lib/psd/node.rb', line 43 def group? is_a?(PSD::Node::Group) || is_a?(PSD::Node::Root) end |
#hidden? ⇒ Boolean
26 27 28 |
# File 'lib/psd/node.rb', line 26 def hidden? !visible? end |
#layer? ⇒ Boolean
39 40 41 |
# File 'lib/psd/node.rb', line 39 def layer? is_a?(PSD::Node::Layer) end |
#psd ⇒ Object
35 36 37 |
# File 'lib/psd/node.rb', line 35 def psd parent.psd end |
#to_hash ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/psd/node.rb', line 51 def to_hash hash = { type: nil, visible: visible?, opacity: @layer.opacity / 255.0, blending_mode: @layer.blending_mode } PROPERTIES.each do |p| hash[p] = self.send(p) end hash end |
#visible? ⇒ Boolean
30 31 32 33 |
# File 'lib/psd/node.rb', line 30 def visible? return false if @layer.clipped? && !next_sibling.visible? force_visible.nil? ? @layer.visible? : force_visible end |