Module: ConDuxml::Array
- Includes:
- Instance, Enumerable
- Defined in:
- lib/con_duxml/array.rb
Overview
XML object array represents a pattern of copies of a this object’s children or referents differentiates between copies using iterator Parameter
Instance Method Summary collapse
-
#each(&block) ⇒ Object
overriding #each to only traverse children and return self on completion, not Enumerator.
-
#instantiate(&block) ⇒ Array[Element]
Flattened array of all duplicated Elements.
-
#size ⇒ Object
size can be Fixnum or a Parameter expression.
Methods included from Instance
Instance Method Details
#each(&block) ⇒ Object
overriding #each to only traverse children and return self on completion, not Enumerator
37 38 39 40 |
# File 'lib/con_duxml/array.rb', line 37 def each &block @children.each &block self end |
#instantiate(&block) ⇒ Array[Element]
Returns flattened array of all duplicated Elements.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/con_duxml/array.rb', line 15 def instantiate(&block) size_expr = size.respond_to?(:to_i) ? size.to_i : size.to_s if size_expr.is_a? Fixnum new_children = [] size_expr.times do |index| nodes.each do |node| new_child = block_given? ? yield(node.dclone, index) : node.dclone new_children << new_child end end new_children else [self] end end |
#size ⇒ Object
size can be Fixnum or a Parameter expression
32 33 34 |
# File 'lib/con_duxml/array.rb', line 32 def size self[:size] end |