Class: Pubid::Bipm::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Bipm::Identifier
- Defined in:
- lib/pubid/bipm/identifier.rb
Overview
Base class for every BIPM identifier AND the flavor's parse/create entry point — mirrors Pubid::Jis::Identifier. Concrete identifiers under Pubid::Bipm::Identifiers descend from this class.
BIPM has several unrelated document families (committee documents,
meetings, the Metrologia journal, the SI Brochure and its appendices,
mises en pratique, and Consultative-Committee guides) with no shared
numbering, so every family-specific attribute lives here as a flat,
nil-defaulted attribute and is used only by the classes that need it. The
canonical to_hash drops any attribute at its default/empty value, so an
unused attribute never appears in a family's serialized hash.
Direct Known Subclasses
Pubid::Bipm::Identifiers::CommitteeDocument, Pubid::Bipm::Identifiers::Guide, Pubid::Bipm::Identifiers::Meeting, Pubid::Bipm::Identifiers::Mep, Pubid::Bipm::Identifiers::MetrologiaArticle, Pubid::Bipm::Identifiers::SiBrochure
Constant Summary collapse
- GROUPS =
Committee acronyms BIPM owns (JCGM excluded — see Pubid::Jcgm).
%w[ CIPM CGPM JCRB CCTF CCQM CCT CCL CCAUV CCU CCM CCEM CCPR CCRI ].freeze
- TYPE_CODES =
Committee document type codes and their printed long-form names. Note DECL prints as "Statement" in BOTH languages in the source data.
%w[REC RES DECN ACT DECL].freeze
- TYPE_NAME_EN =
{ "REC" => "Recommendation", "RES" => "Resolution", "DECN" => "Decision", "ACT" => "Action", "DECL" => "Statement" }.freeze
- TYPE_NAME_FR =
{ "REC" => "Recommandation", "RES" => "Résolution", "DECN" => "Décision", "ACT" => "Action", "DECL" => "Statement" }.freeze
- TYPE_WORD_TO_CODE =
Every printed type word (abbrev + English + French) → canonical code.
TYPE_CODES.each_with_object({}) do |code, map| map[code] = code map[TYPE_NAME_EN[code]] = code map[TYPE_NAME_FR[code]] = code end.freeze
- BIPM_TYPE_MAP =
Polymorphic type map for lutaml::Model key_value (de)serialization: maps each subclass's polymorphic_name to its class name so a stored hash rebuilds the correct identifier type via from_hash.
{ "pubid:bipm:committee-document" => "Pubid::Bipm::Identifiers::CommitteeDocument", "pubid:bipm:meeting" => "Pubid::Bipm::Identifiers::Meeting", "pubid:bipm:metrologia-article" => "Pubid::Bipm::Identifiers::MetrologiaArticle", "pubid:bipm:si-brochure" => "Pubid::Bipm::Identifiers::SiBrochure", "pubid:bipm:mep" => "Pubid::Bipm::Identifiers::Mep", "pubid:bipm:guide" => "Pubid::Bipm::Identifiers::Guide", }.freeze
- PUBLISHER =
Publisher is always "BIPM". A plain constant (not a
publishermethod) so it doesn't shadow the inherited lutamlpublisherattribute, which would otherwise fail serialization type validation. "BIPM"
Class Method Summary collapse
-
.french_connective(group) ⇒ Object
French connective before a committee acronym: "de la" for the (feminine) CGPM, "du" for every other (masculine) committee.
-
.parse(identifier) ⇒ Identifier
Parse a BIPM identifier string into an identifier object.
Instance Method Summary collapse
-
#exclude(*args) ⇒ Object
BIPM keeps the publication year in its own
yearinteger attribute rather than the basedatecomponent, so the base #exclude's :year->:date remap would nil the (unused) inheriteddateand leaveyearintact. - #long? ⇒ Boolean
-
#to_s(**opts) ⇒ Object
Basic string representation.
Methods inherited from Identifier
apply_mappings, #base, #base_document, concrete_class_for, #dated_version_of?, #draft_of?, #drop_supplements, #edition_of?, #eql?, 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
Class Method Details
.french_connective(group) ⇒ Object
French connective before a committee acronym: "de la" for the (feminine) CGPM, "du" for every other (masculine) committee.
116 117 118 |
# File 'lib/pubid/bipm/identifier.rb', line 116 def self.french_connective(group) group == "CGPM" ? "de la" : "du" end |
.parse(identifier) ⇒ Identifier
Parse a BIPM identifier string into an identifier object.
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/pubid/bipm/identifier.rb', line 145 def self.parse(identifier) if identifier.length > Pubid::MAX_INPUT_LENGTH raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE end # Normalize legacy/docnumber-style spellings before parsing # (data/bipm/update_codes.yaml), mirroring Pubid::Ccsds / Pubid::Plateau. normalized = Core::UpdateCodes.apply(identifier, :bipm) parsed = Parser.parse(normalized) Builder.build(parsed) rescue Parslet::ParseFailed => e raise "Failed to parse BIPM identifier '#{identifier}': #{e.}" end |
Instance Method Details
#exclude(*args) ⇒ Object
BIPM keeps the publication year in its own year integer attribute
rather than the base date component, so the base #exclude's
:year->:date remap would nil the (unused) inherited date and leave
year intact. Clear year directly when either alias is excluded so
matches?(row, ignore: [:year]) treats a partial (date-less) reference
as a year wildcard.
130 131 132 133 134 |
# File 'lib/pubid/bipm/identifier.rb', line 130 def exclude(*args) result = super result.year = nil if args.include?(:year) || args.include?(:date) result end |
#long? ⇒ Boolean
120 121 122 |
# File 'lib/pubid/bipm/identifier.rb', line 120 def long? form == "long" end |
#to_s(**opts) ⇒ Object
Basic string representation. Delegates to renderer.
137 138 139 |
# File 'lib/pubid/bipm/identifier.rb', line 137 def to_s(**opts) render(format: :human, **opts) end |