Class: Glossarist::ConceptReference

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/glossarist/concept_reference.rb

Overview

A typed reference to another concept, either local (within the same glossary) or external (in another concept registry).

Local references use concept_id without source. External references use source (a registry URN prefix) and concept_id to identify the target concept, or a direct urn field for formal URN references.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.domain(concept_id) ⇒ Object



27
28
29
# File 'lib/glossarist/concept_reference.rb', line 27

def self.domain(concept_id)
  new(concept_id: concept_id, ref_type: "domain")
end

.section(concept_id) ⇒ Object



31
32
33
# File 'lib/glossarist/concept_reference.rb', line 31

def self.section(concept_id)
  new(concept_id: concept_id, ref_type: "section")
end

Instance Method Details

#cite?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/glossarist/concept_reference.rb', line 44

def cite?
  ref_type == "cite"
end

#dedup_keyObject



48
49
50
# File 'lib/glossarist/concept_reference.rb', line 48

def dedup_key
  concept_id ? [source, concept_id] : [source, concept_id, term]
end

#external?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/glossarist/concept_reference.rb', line 40

def external?
  !local?
end

#local?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/glossarist/concept_reference.rb', line 35

def local?
  %w[local designation cite].include?(ref_type) ||
    (ref_type.nil? && (source.nil? || source.empty?))
end