Class: PSD::Node::Root
Overview
Represents the root node of a Photoshop document
Defined Under Namespace
Classes: RootLayer
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#psd ⇒ Object
readonly
Returns the value of attribute psd.
Attributes inherited from Base
#force_visible, #id, #layer, #left_offset, #name, #parent, #top_offset
Class Method Summary collapse
Instance Method Summary collapse
-
#depth ⇒ Object
The depth of the root node is always 0.
-
#document_dimensions ⇒ Object
Returns the width and height of the entire PSD document.
- #fill_opacity ⇒ Object
-
#initialize(psd) ⇒ Root
constructor
Stores a reference to the parsed PSD and builds the tree hierarchy.
- #opacity ⇒ Object
-
#to_hash ⇒ Object
Recursively exports the hierarchy to a Hash.
Methods inherited from Base
#bottom, #clipping_mask, #color_label, #debug_name, #group?, #height, #hidden?, #layer?, #left, #right, #top, #visible?, #width
Methods included from Locking
#all_locked?, #any_locked?, #composite_locked?, #position_locked?, #transparency_locked?
Methods included from BuildPreview
#renderer, #save_as_png, #to_png
Methods included from LayerComps
#filter_by_comp, #position_in_comp, #visible_in_comp?
Methods included from Search
#children_at_path, #find_by_id
Methods included from Ancestry
#ancestors, #childless?, #descendants, #has_children?, #has_siblings?, #method_missing, #next_sibling, #only_child?, #path, #prev_sibling, #root, #root?, #siblings, #subtree
Constructor Details
#initialize(psd) ⇒ Root
Stores a reference to the parsed PSD and builds the tree hierarchy.
26 27 28 29 30 31 |
# File 'lib/psd/nodes/root.rb', line 26 def initialize(psd) super self.class.layer_for_psd(psd) @psd = psd build_hierarchy 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.
7 8 9 |
# File 'lib/psd/nodes/root.rb', line 7 def children @children end |
#psd ⇒ Object (readonly)
Returns the value of attribute psd.
8 9 10 |
# File 'lib/psd/nodes/root.rb', line 8 def psd @psd end |
Class Method Details
Instance Method Details
#depth ⇒ Object
The depth of the root node is always 0.
39 40 41 |
# File 'lib/psd/nodes/root.rb', line 39 def depth 0 end |
#document_dimensions ⇒ Object
Returns the width and height of the entire PSD document.
34 35 36 |
# File 'lib/psd/nodes/root.rb', line 34 def document_dimensions [document_width, document_height] end |
#fill_opacity ⇒ Object
44 |
# File 'lib/psd/nodes/root.rb', line 44 def fill_opacity; 255; end |
#opacity ⇒ Object
43 |
# File 'lib/psd/nodes/root.rb', line 43 def opacity; 255; end |
#to_hash ⇒ Object
Recursively exports the hierarchy to a Hash
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/psd/nodes/root.rb', line 47 def to_hash { children: children.map(&:to_hash), document: { width: document_width, height: document_height, depth: psd.header.depth, resources: { layer_comps: @psd.layer_comps, guides: @psd.guides, slices: @psd.slices.map(&:to_hash) } } } end |