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, #day_from_kv, #day_to_kv, default_publisher, #emit_code, #month_from_kv, #month_to_kv, #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, #undated_from_kv, #undated_to_kv, #year_from_kv, #year_to_kv
Methods inherited from Pubid::Identifier
apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, #exclude, from_hash, #has_supplement?, #hash, #includes?, #initialize, #matches?, #mr_all_parts, #mr_edition, #mr_languages, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_subpart, #mr_supplement_suffix, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, polymorphic_type_map, #related_to?, #render, #resolve_urn_generator, #root, #sibling_of?, #supplement_of?, #to_hash, #to_mr_string, #to_slug, #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.render}" : ""), ].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 |