Class: Pubid::Components::Relationship
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Components::Relationship
- Defined in:
- lib/pubid/components/relationship.rb
Overview
Relationship component — captures how one identifier relates to others.
Originally modeled as IEEE’s Components::Relationship; promoted to the shared namespace because the same relationship vocabulary applies to ISO, IEC, and other flavors that need to express “revises”, “amends”, “incorporates”, “adopts”, etc.
Shape:
-
relationship_type: one of the VALID_TYPES constants below.
-
related_identifiers: array of identifier objects the relationship points at (e.g., the standards being revised).
-
intermediate_amendments: optional array of identifiers that amended the related identifier between its original publication and the current revision (renders as “… as amended by …”).
-
approved_amendments_flag: when true and no intermediate_amendments are listed, renders “… and its approved amendments”.
Direct Known Subclasses
Constant Summary collapse
- REVISION_OF =
"revision_of"- AMENDMENT_TO =
"amendment_to"- CORRIGENDUM_TO =
"corrigendum_to"- INCORPORATES =
"incorporates"- INCORPORATING =
"incorporating"- ADOPTION_OF =
"adoption_of"- SUPPLEMENT_TO =
"supplement_to"- DRAFT_AMENDMENT_TO =
"draft_amendment_to"- DRAFT_REVISION_OF =
"draft_revision_of"- REAFFIRMATION_OF =
"reaffirmation_of"- REDESIGNATION_OF =
"redesignation_of"- SUPERSEDES =
"supersedes"- PREVIOUSLY_DESIGNATED_AS =
"previously_designated_as"- INCLUDES =
"includes"- VALID_TYPES =
[ REVISION_OF, AMENDMENT_TO, CORRIGENDUM_TO, INCORPORATES, INCORPORATING, ADOPTION_OF, SUPPLEMENT_TO, DRAFT_AMENDMENT_TO, DRAFT_REVISION_OF, REAFFIRMATION_OF, REDESIGNATION_OF, SUPERSEDES, PREVIOUSLY_DESIGNATED_AS, INCLUDES, ].freeze
- PREFIXES =
{ REVISION_OF => "Revision of", AMENDMENT_TO => "Amendment to", CORRIGENDUM_TO => "Corrigendum to", INCORPORATES => "incorporates", ADOPTION_OF => "Adoption of", SUPPLEMENT_TO => "Supplement to", DRAFT_AMENDMENT_TO => "Draft Amendment to", DRAFT_REVISION_OF => "Draft Revision of", REAFFIRMATION_OF => "Reaffirmation of", REDESIGNATION_OF => "Redesignation of", SUPERSEDES => "Supersedes", PREVIOUSLY_DESIGNATED_AS => "Previously designated as", INCLUDES => "Includes", }.freeze
Instance Attribute Summary collapse
-
#approved_amendments_flag ⇒ Object
Returns the value of attribute approved_amendments_flag.
-
#intermediate_amendments ⇒ Object
Returns the value of attribute intermediate_amendments.
-
#related_identifiers ⇒ Object
Returns the value of attribute related_identifiers.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Relationship
constructor
A new instance of Relationship.
- #normalize_incorporating! ⇒ Object
- #render(context: nil) ⇒ Object
- #to_s ⇒ Object
- #validate_relationship_type ⇒ Object
Constructor Details
#initialize(**args) ⇒ Relationship
Returns a new instance of Relationship.
77 78 79 80 81 82 83 84 |
# File 'lib/pubid/components/relationship.rb', line 77 def initialize(**args) @related_identifiers = args.delete(:related_identifiers) @intermediate_amendments = args.delete(:intermediate_amendments) @approved_amendments_flag = args.delete(:approved_amendments_flag) super validate_relationship_type if relationship_type end |
Instance Attribute Details
#approved_amendments_flag ⇒ Object
Returns the value of attribute approved_amendments_flag.
58 59 60 |
# File 'lib/pubid/components/relationship.rb', line 58 def approved_amendments_flag @approved_amendments_flag end |
#intermediate_amendments ⇒ Object
Returns the value of attribute intermediate_amendments.
58 59 60 |
# File 'lib/pubid/components/relationship.rb', line 58 def intermediate_amendments @intermediate_amendments end |
#related_identifiers ⇒ Object
Returns the value of attribute related_identifiers.
58 59 60 |
# File 'lib/pubid/components/relationship.rb', line 58 def @related_identifiers end |
Instance Method Details
#normalize_incorporating! ⇒ Object
86 87 88 89 90 |
# File 'lib/pubid/components/relationship.rb', line 86 def return unless relationship_type == INCORPORATING self.relationship_type = INCORPORATES end |
#render(context: nil) ⇒ Object
110 111 112 |
# File 'lib/pubid/components/relationship.rb', line 110 def render(context: nil) to_s end |
#to_s ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/pubid/components/relationship.rb', line 100 def to_s return "" if .nil? || .empty? prefix = format_relationship_prefix ids = format_identifier_list() return "#{prefix} #{ids}" unless intermediate_clause? "#{prefix} #{ids} #{intermediate_clause}" end |
#validate_relationship_type ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/pubid/components/relationship.rb', line 92 def validate_relationship_type return if VALID_TYPES.include?(relationship_type) raise ArgumentError, "Invalid relationship type: #{relationship_type}. " \ "Valid types: #{VALID_TYPES.join(', ')}" end |