Class: Pubid::Oiml::SupplementIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Identifier
- Pubid::Oiml::SupplementIdentifier
- Defined in:
- lib/pubid/oiml/supplement_identifier.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#supplement_type ⇒ Object
Subclasses override this.
-
#to_s(format: :short) ⇒ Object
Track supplement’s parsed format.
Methods inherited from Identifier
Methods inherited from Identifier
#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#supplement_type ⇒ Object
Subclasses override this
38 39 40 |
# File 'lib/pubid/oiml/supplement_identifier.rb', line 38 def supplement_type raise NotImplementedError, "Subclasses must implement supplement_type" end |
#to_s(format: :short) ⇒ Object
Track supplement’s parsed format
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pubid/oiml/supplement_identifier.rb', line 15 def to_s(format: :short) # Determine base format: explicit parameter takes priority, else use parsed format base_format = if format && format != :short format # Use explicit override elsif base_identifier.class.attributes.key?(:parsed_format) && base_identifier.parsed_format == "long" :long else :short end # Render base with determined format (preserves Edition vs colon) base_str = base_identifier.to_s(format: base_format) base_str = base_str.sub(/\s*\([^)]+\)\s*$/, "").strip # Remove language from base result = "#{supplement_type} (#{year}) to #{base_str}" # Supplements ALWAYS add space before their language result += " (#{language})" if language result end |