class CorrespondenceMarkup::Item

An Item is text in a structure with an associated ID. Typically if would be a word in a sentence. Items are to be related to other items in other structures in the same structure group that have the same ID. When two or more items in the same structure have the same ID, they are considered to be parts of the same item. (For example, in “I let it go”, we might want to identify “let” and “go” as a single item, because they are part of an English phrasal verb “let go”, and its meaning is not quite the sum of the meanings of those two component words.)

Attributes

id[R]

The ID, which identifies the item (possibly not uniquely) within a given structure. An ID can be a comma-separated string of multiple IDs (this is relevant for partial matching, and should only be used when there are more than two structures in a group and one of the structures has less granularity than other structures in that group).

text[R]

The text of the item.

Public Class Methods

new(id, text) click to toggle source

Initialize from ID and text.

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

Public Instance Methods

==(otherItem) click to toggle source

An item is equal to another item with the same ID and text (equality is only used for testing)

# File lib/correspondence-markup/types.rb, line 85
def ==(otherItem)
  otherItem.class == Item && otherItem.id == @id && otherItem.text == @text
end
item?() click to toggle source

Is this an item? (yes)

# File lib/correspondence-markup/types.rb, line 79
def item?
  true
end
to_html(options={}) click to toggle source

Convert to HTML as a *<span>* element with data-id attribute set to the ID according to options for Helpers::text_to_html

# File lib/correspondence-markup/types.rb, line 91
def to_html(options={})
  text_html = text_to_html(@text, options)
  "<span data-id=\"#{@id}\">#{text_html}</span>"
end