Module: ConDuxml::Array

Includes:
Instance
Defined in:
lib/re_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

Instance Method Details

#activateArray[Element]

Returns flattened array of all duplicated Elements.

Returns:

  • (Array[Element])

    flattened array of all duplicated Elements



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/re_duxml/array.rb', line 12

def activate
  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
      source_nodes = if nodes.empty? and self[:ref]
                       [resolve_ref.clone]
                     else
                       nodes.collect do |node| node.clone end
                     end
      source_nodes.each do |node|
        new_children << node
      end
    end
    new_children.flatten
  else
    [self]
  end
end

#sizeObject

size can be Fixnum or a Parameter expression



33
34
35
# File 'lib/re_duxml/array.rb', line 33

def size
  self[:size]
end