Module: Cura::Attributes::HasRoot
Overview
Adds the ‘root` attribute to an object, which defaults to a Component::Group.
Instance Method Summary collapse
-
#add_child(component) ⇒ 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
-
#root ⇒ Component::Group
Get root component for this object.
-
#root=(component) ⇒ Component::Group
Set root component for this object.
Methods included from HasAttributes
Instance Method Details
#add_child(component) ⇒ Component
Add a child to this object’s root component.
45 46 47 |
# File 'lib/cura/attributes/has_root.rb', line 45 def add_child(component) @root.add_child(component) end |
#add_children(*children) ⇒ <Component>
Add multiple children to this object’s root component.
53 54 55 |
# File 'lib/cura/attributes/has_root.rb', line 53 def add_children(*children) @root.add_children(*children) end |
#children(recursive = false) ⇒ <Component>
Get the children of this object.
37 38 39 |
# File 'lib/cura/attributes/has_root.rb', line 37 def children(recursive=false) @root.children(recursive) end |
#children? ⇒ Boolean
Determine if this object’s root component has children.
83 84 85 |
# File 'lib/cura/attributes/has_root.rb', line 83 def children? @root.children? end |
#delete_child(component) ⇒ Component
Remove a child from this object’s root component.
69 70 71 |
# File 'lib/cura/attributes/has_root.rb', line 69 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.
61 62 63 |
# File 'lib/cura/attributes/has_root.rb', line 61 def delete_child_at(index) @root.delete_child_at(index) end |
#delete_children ⇒ HasChildren
Remove all children from object’s root component.
76 77 78 |
# File 'lib/cura/attributes/has_root.rb', line 76 def delete_children @root.delete_children end |
#initialize(attributes = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/cura/attributes/has_root.rb', line 13 def initialize(attributes={}) @root = Component::Group.new(parent: self) super end |
#root ⇒ Component::Group
Get root component for this object.
|
|
# File 'lib/cura/attributes/has_root.rb', line 19
|
#root=(component) ⇒ Component::Group
Set root component for this object.
30 |
# File 'lib/cura/attributes/has_root.rb', line 30 attribute(:root) { |component| set_root(component) } |