Class: Pubid::Ieee::Components::Relationship

Inherits:
Lutaml::Model::Serializable
  • Object
show all
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

Instance Method Summary collapse

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_flagObject

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_amendmentsObject

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

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
  @related_identifiers
end

Instance Method Details

#to_sObject

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 related_identifiers.nil? || related_identifiers.empty?

  # Format: "Relationship Type IEEE Std X, IEEE Std Y, and IEEE Std Z"
  prefix = format_relationship_prefix
  ids = format_identifier_list(related_identifiers)

  # 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_typeObject



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