I.4.12 Iterators
Three iterators are defined in the class:
- “each” iterates on the data and produces pairs of key and values. Each key is an Array
of four elements, and each “values” and Array of 2 to 7 elements. The iterator may have
between 0 and 5 arguments. The arguments are Strings that specify whether some of the
data are to be returned in String or integer format. The consecutive arguments correspond
to the formatting of element id, node id, layer id, sub-layer id and coordinate system id.
- “each_key” iterates on the data and produces Arrays of three elements corresponding to
keys. The iterator may have between 0 and 4 argument. The arguments are Strings that
specify whether some of the data are to be returned in String or integer format.
- “each_values” iterates on the data and produces Arrays of 2 to 7 elements. The iterator
may have 1 or no String argument specifying the Type of the element corresponding to
the coordinate system identifier.
For the meaning of the arguments, see more information in section I.4.10. One difference between the
“each” iterator and the getData method is that the key and values elements are separated into two
Arrays in the block. So the iterator is to be used as follows:
strain.each("int","int","int") do |key,values|
...
end
...
strain.each("int","int","string","string") do |key,values|
...
end
Note that, as the “each_key” and “each_values” iterators return Arrays, one can indifferently recover
an Array argument, or its elements in the arguments of the block that follows the iterator. For example,
in the following lines:
stress.each_key do |stressKey|
...
end
“stressKey” is an Array of three elements. However in the following lines:
stress.each_key("int","int","int") do |elemId,nodeId,layerId|
...
end
the arguments correspond to the different identifiers of the Result key.