Class: Pubid::Ieee::Components::Relationship
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Pubid::Ieee::Components::Relationship
- Defined in:
- lib/pubid/ieee/components/relationship.rb
Overview
Represents a relationship between IEEE identifiers E.g., “Revision of IEEE Std X, Y” or “incorporates A, B, C”
Relationships capture metadata about how identifiers relate to each other:
-
Revision relationships (one standard revises another)
-
Amendment relationships (amendments to base standards)
-
Incorporation relationships (one standard incorporates others)
-
Adoption relationships (adopting external standards)
Example usage:
relationship = Relationship.new(
relationship_type: Relationship::REVISION_OF,
related_identifiers: [Base.parse("IEEE Std 802.11-2012")]
)
relationship.to_s # => "Revision of IEEE Std 802.11-2012"
Constant Summary collapse
- REVISION_OF =
Relationship type constants
"revision_of"- AMENDMENT_TO =
"amendment_to"- CORRIGENDUM_TO =
"corrigendum_to"- INCORPORATES =
"incorporates"- INCORPORATING =
Synonym for incorporates
"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 =
NEW Session 171: For “Includes IEEE Std X” pattern
"includes"- VALID_TYPES =
All valid relationship 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, # NEW Session 171 ].freeze
Instance Attribute Summary collapse
-
#approved_amendments_flag ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause).
-
#intermediate_amendments ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause).
-
#related_identifiers ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause).
Instance Method Summary collapse
-
#initialize(**args) ⇒ Relationship
constructor
Validation.
-
#to_s ⇒ Object
Rendering.
- #validate_relationship_type ⇒ Object
Constructor Details
#initialize(**args) ⇒ Relationship
Validation
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/pubid/ieee/components/relationship.rb', line 68 def initialize(**args) # Extract our non-Lutaml attributes before calling super @related_identifiers = args.delete(:related_identifiers) @intermediate_amendments = args.delete(:intermediate_amendments) @approved_amendments_flag = args.delete(:approved_amendments_flag) # Let Lutaml handle relationship_type super # Normalize INCORPORATING to INCORPORATES for consistent rendering if relationship_type == INCORPORATING self.relationship_type = INCORPORATES end # Validate after initialization validate_relationship_type if relationship_type end |
Instance Attribute Details
#approved_amendments_flag ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause)
64 65 66 |
# File 'lib/pubid/ieee/components/relationship.rb', line 64 def approved_amendments_flag @approved_amendments_flag end |
#intermediate_amendments ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause)
64 65 66 |
# File 'lib/pubid/ieee/components/relationship.rb', line 64 def intermediate_amendments @intermediate_amendments end |
#related_identifiers ⇒ Object
Use regular Ruby attributes to avoid circular dependency related_identifiers: Array of Base identifiers intermediate_amendments: Array of Base identifiers (for “as amended by” clause)
64 65 66 |
# File 'lib/pubid/ieee/components/relationship.rb', line 64 def @related_identifiers end |
Instance Method Details
#to_s ⇒ Object
Rendering
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/pubid/ieee/components/relationship.rb', line 94 def to_s return "" if .nil? || .empty? # Format: "Relationship Type IEEE Std X, IEEE Std Y, and IEEE Std Z" prefix = format_relationship_prefix ids = format_identifier_list() # Add intermediate amendments if present (for "as amended by" clause) if intermediate_amendments && !intermediate_amendments.empty? amendments = format_identifier_list(intermediate_amendments) "#{prefix} #{ids} as amended by #{amendments}" elsif approved_amendments_flag # "and its approved amendments" clause (no specific list) "#{prefix} #{ids} and its approved amendments" else "#{prefix} #{ids}" end end |
#validate_relationship_type ⇒ Object
86 87 88 89 90 91 |
# File 'lib/pubid/ieee/components/relationship.rb', line 86 def validate_relationship_type unless VALID_TYPES.include?(relationship_type) raise ArgumentError, "Invalid relationship type: #{relationship_type}. " \ "Valid types: #{VALID_TYPES.join(', ')}" end end |