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
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(**opts) ⇒ String
Generate URN for this identifier.
Methods inherited from Identifier
#all_parts_from_kv, #all_parts_to_kv, #build_code, build_type_map, #copublishers_from_kv, #copublishers_to_kv, default_publisher, #emit_code, from_hash, #number_from_kv, #number_to_kv, parse, #part_from_kv, #part_to_kv, published_typed_stage, #publisher_from_kv, #publisher_to_kv, #stage, #stage_from_kv, #stage_iteration_from_kv, #stage_iteration_to_kv, #stage_to_kv, #subpart_from_kv, #subpart_to_kv, #type, #year_from_kv, #year_to_kv
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
67 68 69 70 71 |
# File 'lib/pubid/iec/single_identifier.rb', line 67 def edition_portion(lang: :en) return nil unless edition&.number "ED#{edition.number}" end |
#language_portion(lang_single: false) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pubid/iec/single_identifier.rb', line 55 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
45 46 47 48 49 50 51 52 53 |
# File 'lib/pubid/iec/single_identifier.rb', line 45 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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pubid/iec/single_identifier.rb', line 19 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(**opts) ⇒ String
Generate URN for this identifier
15 16 17 |
# File 'lib/pubid/iec/single_identifier.rb', line 15 def to_s(**opts) render(format: :human, **opts) end |