Class: Compo::ArrayComposite
- Inherits:
-
Object
- Object
- Compo::ArrayComposite
- Extended by:
- Forwardable
- Includes:
- Composite
- Defined in:
- lib/compo/array_composite.rb
Overview
Implementation of Composite that stores its children in an Array.
IDs for items entering a ListComposite must be numeric, and will change if an item with an ID less than the item in question is deleted or inserted. This means the ID function for objects in a ListComposite may report different values at different times.
Adding an object at an occupied ID moves the occupant and those at successive IDs up by one.
Direct Known Subclasses
Instance Method Summary collapse
-
#children ⇒ Hash
Returns the ArrayComposite’s children, as a Hash.
-
#initialize ⇒ ArrayComposite
constructor
Initialises an ArrayComposite.
Methods included from Composite
#add, #get_child, #remove, #remove_id
Constructor Details
#initialize ⇒ ArrayComposite
Initialises an ArrayComposite
23 24 25 |
# File 'lib/compo/array_composite.rb', line 23 def initialize @children = [] end |
Instance Method Details
#children ⇒ Hash
Returns the ArrayComposite’s children, as a Hash
38 39 40 |
# File 'lib/compo/array_composite.rb', line 38 def children Hash[(0...@children.size).zip(@children)] end |