class CorrespondenceMarkup::StructureGroup
A structure group is a group of structures. Different structures in one structure group all represent the same information, but in different “languages”. Items in different structures with the same item ID are shown in the UI as being translations of each other. (Items with the same ID in the same structure are also shown as related, and are presumed to be different parts of a single virtual item.)
Attributes
The array of structures
Public Class Methods
Initialize from the structures
# File lib/correspondence-markup/types.rb, line 234 def initialize(structures) @structures = structures end
Public Instance Methods
A structure group is equal to another structure group that has the same structures (equality is only used for testing)
# File lib/correspondence-markup/types.rb, line 240 def ==(otherStructureGroup) otherStructureGroup.class == StructureGroup && otherStructureGroup.structures == @structures end
Convert to HTML as a *<div>* of CSS class “structure-group” that contains the HTML outputs from the structures. Options for Helpers::text_to_html can be provided as single true/false value, or, as arrays of values, in which case the individual values are mapped to the corresponding structures.
# File lib/correspondence-markup/types.rb, line 248 def to_html(options={}) numStructures = structures.length structureOptions = Array.new(numStructures) for i in 0...numStructures do structureOptions[i] = {} end for key in options.keys do value = options[key] if value.kind_of? Array for i in 0...([value.length, numStructures].min) do structureOptions[i][key] = value[i] end else for i in 0...numStructures do structureOptions[i][key] = value end end end structureHtmls = (0...(structures.length)).map{|i| @structures[i].to_html(structureOptions[i])} "<div class=\"structure-group\">\n " + structureHtmls.join("").chomp("\n").gsub("\n", "\n ") + "\n</div>\n" end