class CorrespondenceMarkup::ItemGroup

A group of items & non-items that will form part of a structure. Typically an item group is one line of items (i.e. words) and non-items, or maybe two or three lines which naturally group together within the overall structure (and which cannot be separated because they translate to a single line in one of the other structures in the same structure group). Item groups with the same ID in different structures in the same structure group are related to each other, and may be shown next to each other in the UI when the “Interleave” option is chosen.

Attributes

content[R]

The array of items and non-items

id[R]

The ID which is unique in the structure. It identifies the item group uniquely within the structure. It also serves as a default prefix when parsing IDs for individual items.

Public Class Methods

new(id, content) click to toggle source

Initialize from ID and array of items and non-items

# File lib/correspondence-markup/types.rb, line 147
def initialize(id, content)
  @id = id
  @content = content
end

Public Instance Methods

==(otherItemGroup) click to toggle source

An item group is equal to another item group with the same IDs and the same content (equality is only used for testing)

# File lib/correspondence-markup/types.rb, line 154
def ==(otherItemGroup)
  otherItemGroup.class == ItemGroup && otherItemGroup.id == @id && otherItemGroup.content == @content
end
to_html(options={}) click to toggle source

Convert to HTML as a *<div>* tag with class item-group, data-group-id attribute equal to the ID, and containing the HTML output for the content items and non-items (with those converted according to the options for Helpers::text_to_html).

# File lib/correspondence-markup/types.rb, line 161
def to_html(options={})
  "<div class=\"item-group\" data-group-id=\"#{@id}\">\n  " + 
    @content.map{|x| x.to_html(options)}.join("") + "\n</div>\n"
end