Share

WSStructure

A structure blob field of a WSRowObject, i.e. a field that contains an array of structured data.

It is a collection of WSStructureRow objects, each of which represents a single row / entry in the structure. The collection has a fixed length which can be updated with the length= method. You cannot dynamically insert or remove objects, you must first set the length and access objects by their index.

If any changes are made to the length or the WSStructureRow objects, the write method must be used on both this object and the parent WSRowObject.

Methods:

[] (Get Index)

#[(index)] ⇒ WSStructureRow?

EXCHANGE, UI

Returns the object from the collection at the specified index.

Parameters

Name Type(s) Description
index Integer The index requested (zero-based).
Return WSStructureRow, nil The object found, or nil if there is no object at this index.

each

#each { |row| ... } ⇒ WSStructureRow

EXCHANGE, UI

Iterates through the collection, yielding a WSStructureRow object. This is similar to iterating through the rows of a table.

Examples

struct.each { |row| puts row['date_time'] }
struct.each.each do |row|
  puts row['date_time']
end

length

#length ⇒ Integer

EXCHANGE, UI

Returns the length of the structure, i.e. how many rows it contains. Each row is a WSStructureRow object.

length= (Set)

#length=(length) ⇒ void

EXCHANGE, UI

Sets the length of the structure, i.e. how many rows it contains. Each row is a WSStructureRow object.

Examples

To add to the structure, you must first use this method to set the appropriate length. You can also reference the current length, e.g. to add one new row:

structure.length = structure.length + 1

Parameters

Name Type(s) Description
length Integer

write

#write ⇒ void

EXCHANGE, UI

Writes any changes to this object and the WSStructureRow objects it contains.

The #write method on the parent WSRowObject must also be used.

Was this information helpful?