Class: Pubid::Oiml::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Identifier
- Pubid::Oiml::SingleIdentifier
- Defined in:
- lib/pubid/oiml/single_identifier.rb
Direct Known Subclasses
Identifiers::BasicPublication, Identifiers::Document, Identifiers::ExpertReport, Identifiers::Guide, Identifiers::Recommendation, Identifiers::SeminarReport, Identifiers::Vocabulary
Instance Method Summary collapse
- #edition_portion ⇒ Object
- #to_s(format: nil) ⇒ Object
-
#type ⇒ Object
Type is determined by the subclass.
-
#type_string ⇒ Object
Subclasses override this.
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
#edition_portion ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/pubid/oiml/single_identifier.rb', line 70 def edition_portion # Deprecated - kept for compatibility # Use to_s(format: :long) instead if edition && date "#{edition} Edition #{date.year}" elsif date "Edition #{date.year}" else edition end end |
#to_s(format: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pubid/oiml/single_identifier.rb', line 23 def to_s(format: nil) # Use parsed format if not explicitly overridden format ||= (parsed_format == "long" ? :long : :short) result = "#{publisher} #{type_string} #{code}" # Track if we're using Edition format for language spacing using_edition_format = false # Add edition/date portion if edition && date # Has edition number: "6th Edition 2015" result += " #{edition} Edition #{date.year}" using_edition_format = true elsif edition # Edition without year (shouldn't happen but handle it) result += " #{edition}" using_edition_format = true elsif date # Date without edition number if format == :long result += " Edition #{date.year}" using_edition_format = true else result += ":#{date.year}" end end # Add draft stage if present (iteration + stage) if stage || iteration result += " " result += iteration.to_s if iteration result += stage.to_s if stage end # Add language portion - depends on format if language result += if using_edition_format || parsed_format == "short_with_space" " (#{language})" else "(#{language})" end end result end |
#type ⇒ Object
Type is determined by the subclass
19 20 21 |
# File 'lib/pubid/oiml/single_identifier.rb', line 19 def type type_string end |
#type_string ⇒ Object
Subclasses override this
83 84 85 |
# File 'lib/pubid/oiml/single_identifier.rb', line 83 def type_string raise NotImplementedError, "Subclasses must implement type_string" end |