Class: Compo::Composites::Array
- Inherits:
-
Object
- Object
- Compo::Composites::Array
- Extended by:
- Forwardable
- Includes:
- Composite
- Defined in:
- lib/compo/composites/array.rb
Overview
Implementation of Composite that stores its children in an Array.
IDs for items entering an Array 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 an Array 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 array composite’s children, as a Hash.
-
#initialize ⇒ Array
constructor
Initialises an array composite.
Methods included from Composite
#add, #get_child, #get_child_such_that, #remove, #remove_id
Constructor Details
#initialize ⇒ Array
Initialises an array composite
24 25 26 |
# File 'lib/compo/composites/array.rb', line 24 def initialize @children = [] end |
Instance Method Details
#children ⇒ Hash
Returns the array composite’s children, as a Hash
39 40 41 |
# File 'lib/compo/composites/array.rb', line 39 def children ::Hash[(0...@children.size).zip(@children)] end |