Class: Arrolio::Content::TermEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/arrolio/content/term_entry.rb

Overview

A dictionary term entry: optional number, preferred term text, definition Paragraphs, and optional source citation. Maps to the <term> element in standoc vocabulary. Renders as a hanging-indent group in the flow builder.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number: nil, preferred: nil, definition: [], source: nil, id: nil, style_id: :term) ⇒ TermEntry

Returns a new instance of TermEntry.



12
13
14
15
16
17
18
19
20
21
# File 'lib/arrolio/content/term_entry.rb', line 12

def initialize(number: nil, preferred: nil, definition: [],
               source: nil, id: nil, style_id: :term)
  @number = number&.to_s
  @preferred = preferred
  @definition = Array(definition).freeze
  @source = source
  @id = id&.to_s
  @style_id = style_id.to_sym
  freeze
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def definition
  @definition
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def id
  @id
end

#numberObject (readonly)

Returns the value of attribute number.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def number
  @number
end

#preferredObject (readonly)

Returns the value of attribute preferred.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def preferred
  @preferred
end

#sourceObject (readonly)

Returns the value of attribute source.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def source
  @source
end

#style_idObject (readonly)

Returns the value of attribute style_id.



10
11
12
# File 'lib/arrolio/content/term_entry.rb', line 10

def style_id
  @style_id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



27
28
29
30
31
32
33
34
35
# File 'lib/arrolio/content/term_entry.rb', line 27

def ==(other)
  other.is_a?(self.class) &&
    number == other.number &&
    preferred == other.preferred &&
    definition == other.definition &&
    source == other.source &&
    id == other.id &&
    style_id == other.style_id
end

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/arrolio/content/term_entry.rb', line 23

def empty?
  @preferred.nil? && @definition.empty? && @number.nil?
end

#hashObject



38
39
40
# File 'lib/arrolio/content/term_entry.rb', line 38

def hash
  [self.class, number, preferred, definition, source, id, style_id].hash
end