Class: Pubid::Itu::Identifiers::AppendixOfRecommendation

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

Overview

A labelled appendix of a Recommendation — "ITU-T G.101 App. I (05/2000)", "ITU-T G.722 (1988) App. IV (11/2006)".

Structurally the twin of AnnexOfRecommendation: an appendix is published and dated separately from the Recommendation it appends, and may itself carry an amendment/errata ("ITU-T G.729 App. I (2002) Amd. 1"). The label is a Roman numeral rather than a series letter.

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



71
72
73
74
75
76
77
78
79
80
# File 'lib/pubid/itu/identifiers/appendix_of_recommendation.rb', line 71

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

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

#mr_supplement_suffixObject

MR: recurse into the appendixed document and append "app.



65
66
67
68
69
# File 'lib/pubid/itu/identifiers/appendix_of_recommendation.rb', line 65

def mr_supplement_suffix
  label = "#{number}#{material}".downcase.gsub(/[^a-z0-9]/, "")

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

#render_base(**opts) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/pubid/itu/identifiers/appendix_of_recommendation.rb', line 53

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

  result += " App. #{number}"
  result += " #{material}" if material
  result + render_date_suffix
end

#to_urnObject

":appendix:



44
45
46
47
48
49
50
51
# File 'lib/pubid/itu/identifiers/appendix_of_recommendation.rb', line 44

def to_urn
  segments = [base&.to_urn || "urn:itu", "appendix", number&.downcase]
  # Without this the test-vector record and the appendix itself would
  # share a URN.
  segments << material.downcase.gsub(/[^a-z0-9]/, "") if material
  segments << urn_date_segment
  segments.compact.join(":")
end