Class: Coradoc::CoreModel::BibliographyEntry

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/core_model/bibliography_entry.rb

Overview

Individual bibliography entry (reference).

Bibliography entries represent single references within a bibliography, with anchor names for citation linking.

Examples:

Create a bibliography entry

entry = Coradoc::CoreModel::BibliographyEntry.new(
  anchor_name: "ISO712",
  document_id: "ISO 712",
  ref_text: "Cereals and cereal products. Determination of moisture content."
)

Instance Attribute Summary collapse

Attributes inherited from Base

#element_attributes, #id, #metadata_entries, #title

Instance Method Summary collapse

Methods inherited from Base

#accept, #attr, #metadata, #semantically_equivalent?, #set_attr, #set_metadata

Instance Attribute Details

#anchor_nameString? (readonly)

Returns The anchor name for citing this entry (e.g., “ISO712”).

Returns:

  • (String, nil)

    The anchor name for citing this entry (e.g., “ISO712”)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/coradoc/core_model/bibliography_entry.rb', line 29

class BibliographyEntry < Base
  attribute :anchor_name, :string
  attribute :document_id, :string
  attribute :ref_text, :string
  attribute :url, :string

  # Returns a formatted display string combining label and reference text.
  #
  # Uses document_id or anchor_name as the label, falling back to ref_text
  # alone when no label is available.
  #
  # @return [String] formatted citation text
  def display_text
    label = document_id || anchor_name || ''
    ref = ref_text || ''
    label.empty? ? ref : "#{label}: #{ref}"
  end
end

#document_idString? (readonly)

Returns The document identifier (e.g., “ISO 712”).

Returns:

  • (String, nil)

    The document identifier (e.g., “ISO 712”)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/coradoc/core_model/bibliography_entry.rb', line 29

class BibliographyEntry < Base
  attribute :anchor_name, :string
  attribute :document_id, :string
  attribute :ref_text, :string
  attribute :url, :string

  # Returns a formatted display string combining label and reference text.
  #
  # Uses document_id or anchor_name as the label, falling back to ref_text
  # alone when no label is available.
  #
  # @return [String] formatted citation text
  def display_text
    label = document_id || anchor_name || ''
    ref = ref_text || ''
    label.empty? ? ref : "#{label}: #{ref}"
  end
end

#ref_textString? (readonly)

Returns The reference text/citation description.

Returns:

  • (String, nil)

    The reference text/citation description



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/coradoc/core_model/bibliography_entry.rb', line 29

class BibliographyEntry < Base
  attribute :anchor_name, :string
  attribute :document_id, :string
  attribute :ref_text, :string
  attribute :url, :string

  # Returns a formatted display string combining label and reference text.
  #
  # Uses document_id or anchor_name as the label, falling back to ref_text
  # alone when no label is available.
  #
  # @return [String] formatted citation text
  def display_text
    label = document_id || anchor_name || ''
    ref = ref_text || ''
    label.empty? ? ref : "#{label}: #{ref}"
  end
end

#urlString? (readonly)

Returns Optional URL for the reference.

Returns:

  • (String, nil)

    Optional URL for the reference



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/coradoc/core_model/bibliography_entry.rb', line 29

class BibliographyEntry < Base
  attribute :anchor_name, :string
  attribute :document_id, :string
  attribute :ref_text, :string
  attribute :url, :string

  # Returns a formatted display string combining label and reference text.
  #
  # Uses document_id or anchor_name as the label, falling back to ref_text
  # alone when no label is available.
  #
  # @return [String] formatted citation text
  def display_text
    label = document_id || anchor_name || ''
    ref = ref_text || ''
    label.empty? ? ref : "#{label}: #{ref}"
  end
end

Instance Method Details

#display_textString

Returns a formatted display string combining label and reference text.

Uses document_id or anchor_name as the label, falling back to ref_text alone when no label is available.

Returns:

  • (String)

    formatted citation text



41
42
43
44
45
# File 'lib/coradoc/core_model/bibliography_entry.rb', line 41

def display_text
  label = document_id || anchor_name || ''
  ref = ref_text || ''
  label.empty? ? ref : "#{label}: #{ref}"
end