Class: Coradoc::AsciiDoc::Model::Inline::Anchor

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/asciidoc/model/inline/anchor.rb

Overview

Anchor inline element for creating cross-reference targets in AsciiDoc documents.

Anchors create reference points that can be linked to from other parts of the document using cross-references.

Examples:

Create an anchor

anchor = Coradoc::AsciiDoc::Model::Inline::Anchor.new
anchor.id = "section1"
anchor.to_adoc # => "[[section1]]"

Validation fails without id

anchor = Coradoc::AsciiDoc::Model::Inline::Anchor.new
anchor.validate # Returns validation errors

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#inline?

Methods inherited from Base

#block_level?, #inline?, #serialize_content, #simplify_block_content, #to_adoc, #to_h, visit, #visit

Instance Attribute Details

#idString (readonly)

Returns The anchor identifier.

Returns:

  • (String)

    The anchor identifier



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/coradoc/asciidoc/model/inline/anchor.rb', line 27

class Anchor < Base
  attribute :id, :string

  def validate
    errors = super
    return unless id.nil? || id.empty?

    errors <<
      Lutaml::Model::Error.new('ID cannot be nil or empty for Anchor')
  end
end

Instance Method Details

#validateObject



30
31
32
33
34
35
36
# File 'lib/coradoc/asciidoc/model/inline/anchor.rb', line 30

def validate
  errors = super
  return unless id.nil? || id.empty?

  errors <<
    Lutaml::Model::Error.new('ID cannot be nil or empty for Anchor')
end