Class: Pubid::Itu::Identifiers::AnnexOfRecommendation

Inherits:
Pubid::Itu::Identifier show all
Defined in:
lib/pubid/itu/identifiers/annex_of_recommendation.rb

Overview

A labelled annex of a Recommendation — "ITU-T A.23 Annex A (06/2014)", "ITU-T Z.100 Annex F3 (10/2019)", "ITU-T G.729 Annex C+ (02/2000)".

The annex is a document in its own right: it is published (and dated) separately from the Recommendation it annexes, and may itself carry a corrigendum/errata/amendment ("ITU-T G.729 Annex B (1996) Cor. 3 (03/2001)").

Distinct from Identifiers::Annex, which models the label-less "Annex to ITU OB No. 1000" form (a prefix rendering with its own i18n templates). Keeping them apart keeps each _type — already persisted in relaton index rows — unambiguous.

Constant Summary

Constants inherited from Pubid::Itu::Identifier

Pubid::Itu::Identifier::LANGUAGES

Instance Method Summary collapse

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_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, #urn_supplement_type, #urn_type_code, #year

Constructor Details

This class inherits a constructor from Pubid::Itu::Identifier

Instance Method Details

#==(other) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/pubid/itu/identifiers/annex_of_recommendation.rb', line 67

def ==(other)
  return false unless other.instance_of?(self.class)

  base == other.base &&
    number == other.number &&
    date == other.date &&
    language == other.language &&
    common_text_twin == other.common_text_twin
end

#mr_supplement_suffixObject

MR: recurse into the annexed document and append "annex.



59
60
61
62
63
64
65
# File 'lib/pubid/itu/identifiers/annex_of_recommendation.rb', line 59

def mr_supplement_suffix
  # "C+" -> "cplus", not "c" — the MR charset excludes "+", and
  # dropping it would collide with the sibling "Annex C".
  label = number.to_s.downcase.gsub("+", "plus").gsub(/[^a-z0-9]/, "")

  ["annex", label.empty? ? nil : label, date&.year].compact.join(".")
end

#render_base(**opts) ⇒ Object



49
50
51
52
53
# File 'lib/pubid/itu/identifiers/annex_of_recommendation.rb', line 49

def render_base(**opts)
  result = base ? base.render_base(**opts) : "#{publisher}-#{sector}"

  "#{result} Annex #{number}#{render_date_suffix}"
end

#to_urnObject

":annex:



43
44
45
46
47
# File 'lib/pubid/itu/identifiers/annex_of_recommendation.rb', line 43

def to_urn
  segments = [base&.to_urn || "urn:itu", "annex", number&.downcase]
  segments << urn_date_segment
  segments.compact.join(":")
end