Module: Cura::Attributes::HasRoot
Overview
Adds the ‘root` attribute to an object, which defaults to a Component::Group.
Instance Attribute Summary collapse
-
#root ⇒ Component::Group
Get root component for this object.
Instance Method Summary collapse
-
#add_child(component_or_type, attributes = {}) ⇒ Component
Add a child to this object’s root component.
-
#add_children(*children) ⇒ <Component>
Add multiple children to this object’s root component.
-
#children(recursive = false) ⇒ <Component>
Get the children of this object.
-
#children? ⇒ Boolean
Determine if this object’s root component has children.
-
#delete_child(component) ⇒ Component
Remove a child from this object’s root component.
-
#delete_child_at(index) ⇒ Component
Remove a child from object’s root component at the given index.
-
#delete_children ⇒ HasChildren
Remove all children from object’s root component.
- #initialize(attributes = {}) ⇒ Object
Methods included from HasAttributes
Instance Attribute Details
#root ⇒ Component::Group
Get root component for this object.
23 24 25 |
# File 'lib/cura/attributes/has_root.rb', line 23 def root @root end |
Instance Method Details
#add_child(component_or_type, attributes = {}) ⇒ Component
Add a child to this object’s root component.
54 55 56 |
# File 'lib/cura/attributes/has_root.rb', line 54 def add_child(component_or_type, attributes={}) @root.add_child(component_or_type, attributes) end |
#add_children(*children) ⇒ <Component>
Add multiple children to this object’s root component.
62 63 64 |
# File 'lib/cura/attributes/has_root.rb', line 62 def add_children(*children) @root.add_children(*children) end |
#children(recursive = false) ⇒ <Component>
Get the children of this object.
41 42 43 |
# File 'lib/cura/attributes/has_root.rb', line 41 def children(recursive=false) @root.children(recursive) end |
#children? ⇒ Boolean
Determine if this object’s root component has children.
92 93 94 |
# File 'lib/cura/attributes/has_root.rb', line 92 def children? @root.children? end |
#delete_child(component) ⇒ Component
Remove a child from this object’s root component.
78 79 80 |
# File 'lib/cura/attributes/has_root.rb', line 78 def delete_child(component) @root.delete_child(component) end |
#delete_child_at(index) ⇒ Component
Remove a child from object’s root component at the given index.
70 71 72 |
# File 'lib/cura/attributes/has_root.rb', line 70 def delete_child_at(index) @root.delete_child_at(index) end |
#delete_children ⇒ HasChildren
Remove all children from object’s root component.
85 86 87 |
# File 'lib/cura/attributes/has_root.rb', line 85 def delete_children @root.delete_children end |