Class: Pubid::Itu::Identifiers::CombinedIdentifier
- Inherits:
-
Pubid::Itu::Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Pubid::Itu::Identifier
- Pubid::Itu::Identifiers::CombinedIdentifier
- Includes:
- StandardSerialization
- Defined in:
- lib/pubid/itu/identifiers/combined_identifier.rb
Overview
Combined (joint) recommendation — a single document published under two or more series/number designations at once. Format: ITU-T G.780/Y.1351 (dual) ITU-T G.780/Y.1351/Z.1362 (triple)
The primary designation lives on the base series/code; every
additional designation is a Components::Designation in combined
(one for a dual form, two+ for triple).
Constant Summary
Constants inherited from Pubid::Itu::Identifier
Pubid::Itu::Identifier::LANGUAGES
Instance Method Summary collapse
- #==(other) ⇒ Object
- #combined_from_kv(model, value) ⇒ Object
- #combined_to_kv(model, doc) ⇒ Object
-
#render_base(**_opts) ⇒ Object
Rendering hooks into
render_base(notto_s) so that any wrapper composing this identifier — AnnexOfRecommendation, which renders "<base.render_base> Annex
Methods included from StandardSerialization
Methods inherited from Pubid::Itu::Identifier
#base_from_kv, #base_to_kv, #code_for, #common_text_twin_from_kv, #common_text_twin_to_kv, #date_for, #emit_kv, #exclude_from_nested, #imp_marker_from_kv, #imp_marker_to_kv, #initialize, #month_from_kv, #month_to_kv, #mr_number_with_part, #mr_publisher, #mr_type, normalize_to_s_opts, #number, #number_from_kv, #number_to_kv, parse, #parts_from_kv, #parts_to_kv, #qualifier_from_kv, #qualifier_glued_from_kv, #qualifier_glued_to_kv, #qualifier_to_kv, #render_date_suffix, #render_language_suffix, #sector_from_kv, #sector_to_kv, #series_from_kv, #series_suffix_from_kv, #series_suffix_spaced_from_kv, #series_suffix_spaced_to_kv, #series_suffix_to_kv, #series_to_kv, #subseries_from_kv, #subseries_to_kv, #to_s, #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_s, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Itu::Identifier
Instance Method Details
#==(other) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/pubid/itu/identifiers/combined_identifier.rb', line 103 def ==(other) return false unless other.is_a?(CombinedIdentifier) sector == other.sector && series == other.series && code == other.code && combined == other.combined && date == other.date && version == other.version && series_word == other.series_word && series_dash == other.series_dash && == other. && range_end == other.range_end && language == other.language end |
#combined_from_kv(model, value) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pubid/itu/identifiers/combined_identifier.rb', line 54 def combined_from_kv(model, value) model.combined = Array(value).map do |row| row = row.transform_keys(&:to_s) Components::Designation.new( series: Components::Series.new(series: row["series"].to_s), code: Components::Code.new( number: row["number"].to_s, series_suffix: row["series_suffix"]&.to_s, series_suffix_spaced: !!row["series_suffix_spaced"], subseries: row["subseries"]&.to_s, parts: Array(row["parts"]).map(&:to_s), qualifier: row["qualifier"]&.to_s, qualifier_glued: !!row["qualifier_glued"], ), ) end end |
#combined_to_kv(model, doc) ⇒ Object
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 |
# File 'lib/pubid/itu/identifiers/combined_identifier.rb', line 27 def combined_to_kv(model, doc) designations = model.combined return if designations.nil? || designations.empty? rows = designations.map do |d| row = { "series" => d.series&.series.to_s, "number" => d.code&.number.to_s } row["subseries"] = d.code.subseries.to_s if d.code&.subseries row["parts"] = d.code.parts.map(&:to_s) if d.code&.parts&.any? # Each emitted only when set, so an ordinary joint designation's # row keeps its existing two-key shape. if d.code&.series_suffix row["series_suffix"] = d.code.series_suffix.to_s row["series_suffix_spaced"] = true if d.code.series_suffix_spaced end if d.code&.qualifier row["qualifier"] = d.code.qualifier.to_s row["qualifier_glued"] = true if d.code.qualifier_glued end row end doc.add_child( Lutaml::KeyValue::DataModel::Element.new("combined", rows), ) end |
#render_base(**_opts) ⇒ Object
Rendering hooks into render_base (not to_s) so that any wrapper
composing this identifier — AnnexOfRecommendation, which renders
"<base.render_base> Annex
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/pubid/itu/identifiers/combined_identifier.rb', line 77 def render_base(**_opts) result = "#{publisher}-#{sector}" # Add primary series and code result += if series " #{series}#{series_dash ? '-' : '.'}#{code}" else " #{code}" end result += "-#{range_end}" if range_end # Add additional designations if combined&.any? result += "/#{combined.join('/')}" end result += " series" if series_word result += " attachment" if # Add version marker if present — always between code and date result += " (V#{version})" if version result + render_date_suffix end |