Class: Pubid::Itu::Identifiers::Supplement
- Inherits:
-
Pubid::Itu::Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Pubid::Itu::Identifier
- Pubid::Itu::Identifiers::Supplement
- Defined in:
- lib/pubid/itu/identifiers/supplement.rb
Overview
Supplement identifier (Suppl.) Pattern: "ITU-T H Suppl. 1", "ITU-T E.156 Suppl. 2"
Direct Known Subclasses
Constant Summary
Constants inherited from Pubid::Itu::Identifier
Pubid::Itu::Identifier::LANGUAGES
Instance Method Summary collapse
-
#==(other) ⇒ Object
Shared by Amendment / Corrigendum / Errata.
-
#mr_type ⇒ Object
A supplement carries no
mr_supplement_suffix, so the shared MR renderer slugs it FLAT, from the sector/series/code Builder#build_ supplement copied up from its base — which never consults the base's class. -
#render_supplement(label) ⇒ Object
Shared by every supplement type — Suppl./Amd./Cor./Err./Add.
- #series_word_from_kv(model, value) ⇒ Object
- #supplement_sector_to_kv(model, doc) ⇒ Object
- #supplement_series_to_kv(model, doc) ⇒ Object
-
#supplement_series_word_to_kv(model, doc) ⇒ Object
Like sector/series above: the series group's "series" word is part of the base-less form's identity only.
- #to_s ⇒ Object
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, 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_base, #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, #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_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::Itu::Identifier
Instance Method Details
#==(other) ⇒ Object
Shared by Amendment / Corrigendum / Errata.
instance_of? (not is_a?) so a Suppl. never equals an Amd./Cor./
Err. with the same ordinal, and so the comparison stays symmetric —
with is_a? a Supplement accepted an Amendment but not the reverse.
sector/series are compared ONLY for the base-less, series-only form ("ITU-T A Suppl. 2"), where they are the document's whole identity. When a base is present they are copies of the base's (set by Builder#build_supplement) and are deliberately not serialized (see supplement_sector_to_kv), so comparing them would make a parsed identifier unequal to the same identifier rebuilt via from_hash.
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 134 def ==(other) return false unless other.instance_of?(self.class) return false unless base == other.base && number == other.number && date == other.date return true if base sector == other.sector && series == other.series && series_word == other.series_word end |
#mr_type ⇒ Object
A supplement carries no mr_supplement_suffix, so the shared MR
renderer slugs it FLAT, from the sector/series/code Builder#build_
supplement copied up from its base — which never consults the base's
class. Without this, the supplement of a Report and the supplement of
the same-numbered Recommendation produce one slug (and to_slug is an
output filename, so one overwrites the other) — exactly the collision
this type exists to prevent. root walks through an intervening annex
or appendix, so a supplement of an annex of a Report is covered too.
86 87 88 89 90 91 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 86 def mr_type type = super return type unless root.is_a?(Report) [type, "report"].compact.join(".") end |
#render_supplement(label) ⇒ Object
Shared by every supplement type — Suppl./Amd./Cor./Err./Add. differ only in the label, so each subclass supplies its own and nothing else.
label is the canonical spelling with its period; the parser also
accepts the period-less input (see Parser#supplement_type), which
normalizes here.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 99 def render_supplement(label) result = base ? base.to_s : "#{publisher}-#{sector}" # Add series if no base if !base && series result += " #{series}" result += " series" if series_word end result += slash_joined ? "/" : " " result += label result += " " unless number_glued result += number.to_s result += render_date_suffix result end |
#series_word_from_kv(model, value) ⇒ Object
74 75 76 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 74 def series_word_from_kv(model, value) model.series_word = value end |
#supplement_sector_to_kv(model, doc) ⇒ Object
52 53 54 55 56 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 52 def supplement_sector_to_kv(model, doc) return unless model.base.nil? emit_kv(doc, "sector", model.sector&.sector) end |
#supplement_series_to_kv(model, doc) ⇒ Object
58 59 60 61 62 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 58 def supplement_series_to_kv(model, doc) return unless model.base.nil? emit_kv(doc, "series", model.series&.series) end |
#supplement_series_word_to_kv(model, doc) ⇒ Object
Like sector/series above: the series group's "series" word is part of the base-less form's identity only. With a base it belongs to (and is serialized by) the base.
67 68 69 70 71 72 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 67 def supplement_series_word_to_kv(model, doc) return unless model.base.nil? return unless model.series_word doc["series_word"] = true end |
#to_s ⇒ Object
118 119 120 |
# File 'lib/pubid/itu/identifiers/supplement.rb', line 118 def to_s render_supplement("Suppl.") end |