Class: Coradoc::Reference::Edge
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Coradoc::Reference::Edge
- Defined in:
- lib/coradoc/reference/edge.rb,
lib/coradoc/reference/edge/kind.rb,
lib/coradoc/reference/edge/options.rb,
lib/coradoc/reference/edge/link_options.rb,
lib/coradoc/reference/edge/include_options.rb,
lib/coradoc/reference/edge/citation_options.rb,
lib/coradoc/reference/edge/image_ref_options.rb,
lib/coradoc/reference/edge/navigation_options.rb,
lib/coradoc/reference/edge/footnote_ref_options.rb
Overview
Directed edge: a Content node references another Content via an Address.
Every reference in coradoc — navigation, citation, hyperlink,
include, image, footnote — is one Edge with a different kind.
The kind is a label for materialization; resolution is kind-agnostic.
Edge.new(
kind: :navigation,
address: Address.parse("ELF-5005-1#sec-3"),
source_id: "para-42",
label: "Section 3"
)
Defined Under Namespace
Modules: Kind Classes: CitationOptions, FootnoteRefOptions, ImageRefOptions, IncludeOptions, LinkOptions, NavigationOptions, Options
Class Method Summary collapse
-
.build(kind:, address:, source_id: nil, label: nil, options: nil) ⇒ Object
Build an Edge with the given kind.
- .kinds ⇒ Object
- .register_kind(name, options_class: nil) ⇒ Object
Class Method Details
.build(kind:, address:, source_id: nil, label: nil, options: nil) ⇒ Object
Build an Edge with the given kind. Options are coerced to the
kind's options class (if any) via the Kind registry — never
hand-rolled. Raises UnknownKindError for kinds that were never
registered — external kinds register via register_kind (OCP).
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/coradoc/reference/edge.rb', line 43 def build(kind:, address:, source_id: nil, label: nil, options: nil) entry = Kind.entry_for(kind) unless entry raise Coradoc::Reference::UnknownKindError, "Unknown reference kind #{kind.inspect} — " \ 'register it via Edge.register_kind' end new( kind: kind.to_s, address: address, source_id: source_id, label: label, options: (, entry.) ) end |