Class: Pubid::Iec::SingleIdentifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Identifier
- Pubid::Iec::SingleIdentifier
- Defined in:
- lib/pubid/iec/single_identifier.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Identifier
Identifier::EXTRA_CREATE_KLASS_FILES
Instance Method Summary collapse
- #edition_portion(lang: :en) ⇒ Object
- #language_portion(lang_single: false) ⇒ Object
- #number_portion(lang_single: false) ⇒ Object
- #publisher_portion(lang: :en) ⇒ Object
-
#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ String
Generate URN for this identifier.
Methods inherited from Identifier
Methods inherited from Pubid::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, #year
Constructor Details
This class inherits a constructor from Pubid::Identifier
Instance Method Details
#edition_portion(lang: :en) ⇒ Object
73 74 75 76 77 |
# File 'lib/pubid/iec/single_identifier.rb', line 73 def edition_portion(lang: :en) return nil unless edition&.number "ED#{edition.number}" end |
#language_portion(lang_single: false) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pubid/iec/single_identifier.rb', line 61 def language_portion(lang_single: false) return "" unless languages&.any? [ "(", languages.map do |lang| lang.to_s(lang_single: lang_single) end.join(lang_single ? "/" : ","), ")", ].join end |
#number_portion(lang_single: false) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/pubid/iec/single_identifier.rb', line 51 def number_portion(lang_single: false) [ (number ? number.to_s : ""), (part ? "-#{part}" : ""), (subpart ? "-#{subpart}" : ""), (stage_iteration ? ".#{stage_iteration}" : ""), (date ? ":#{date.year}" : ""), ].join end |
#publisher_portion(lang: :en) ⇒ Object
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 |
# File 'lib/pubid/iec/single_identifier.rb', line 25 def publisher_portion(lang: :en) # IEC identifiers can have copublishers (e.g., IEC/IEEE, ISO/IEC) # Build publisher string pub_string = if copublishers&.any? # Has copublishers: "IEC/IEEE" or "ISO/IEC" ([publisher] + copublishers).map(&:body).join("/") else # No copublishers: just "IEC" publisher.body end # Add type abbreviation if present if typed_stage && !typed_stage.abbreviation.empty? abbr = typed_stage.abbreviation # For copublishers or empty abbr, use space; otherwise use slash pub_string += if copublishers&.any? || abbr == "" (abbr == "" ? "" : " #{abbr}") else "/#{abbr}" end end pub_string end |
#to_s(lang: :en, lang_single: false, with_edition: false) ⇒ String
Generate URN for this identifier
15 16 17 18 19 20 21 22 23 |
# File 'lib/pubid/iec/single_identifier.rb', line 15 def to_s(lang: :en, lang_single: false, with_edition: false) [].tap do |parts| parts << publisher_portion(lang: lang) parts << number_portion(lang_single: lang_single) parts << edition_portion(lang: lang) if with_edition end.compact.join(" ").tap do |s| s << language_portion(lang_single: lang_single) if languages&.any? end end |