Class: Pubid::Ieee::Identifiers::IecIeeeCopublished
- Inherits:
-
Pubid::Ieee::Identifier
- Object
- Lutaml::Model::Serializable
- Pubid::Identifier
- Pubid::Ieee::Identifier
- Pubid::Ieee::Identifiers::IecIeeeCopublished
- Defined in:
- lib/pubid/ieee/identifiers/iec_ieee_copublished.rb
Overview
IEC/IEEE Copublished Identifier - standards copublished by IEC and IEEE. Example: "IEC/IEEE 60079-30-2/D5 IEC:2013 (10/07)"
The printed IEC/IEEE number is stored as split index columns rather than
a verbatim string: number (bare-digit narrowing key), parts (matched
within the bucket), separators (per-part ./-, since a single code
mixes them, e.g. 60076.57-1202), and the trailing publication year
(inherited from the base; attached with year_sep, always - in
practice). The verbatim copublished_number is reconstructed from these
for rendering — see #copublished_number — so it is NOT serialized.
Constant Summary collapse
- STAGE_PREFIX =
A stage word printed ahead of the number (
FDIS 60079-30-2,CD2 P62704-5 ED1,TS P61869-105 ED1). The lookahead — the next token must start like a document number — is what stops this eating a number that merely begins with a letter. /\A[A-Z]+\d*\s+(?=P?\d)/- CODE_END =
Inside the number token, the printed code stops early at:
- a colon-attached publication year (
62582-2:2022); - a dash/dot-attached 19xx/20xx year (
62395.1-2024 Redline) — only one a descriptive tail stranded inside the code gets here, since #peel_copublished_year moves a genuinely trailing year into theyearattribute. The 19/20 prefix keeps a part that merely looks like a year (60076.57-1202) from matching; - a glued parenthetical (
62704-1(E)), which is a language marker rather than part of the number.
- a colon-attached publication year (
/:\d{4}|[-.](?:19|20)\d{2}\z|\(/
Instance Attribute Summary
Attributes inherited from Pubid::Ieee::Identifier
Instance Method Summary collapse
-
#code_end_index(code) ⇒ Object
Index at which the printed code ends and descriptive text begins.
-
#copublished_number(mark = "") ⇒ Object
The printed IEC/IEEE number, rebuilt losslessly from the split columns (the renderer/urn read this).
-
#exclude(*args) ⇒ Object
The base IEEE #exclude already nils year/month/day; also reset the year separator (a format sibling of the scalar year, per the CSA lesson) so a date-less reference matches a
:-dated form too. -
#marked_code(mark) ⇒ Object
number+ #parts_suffix with the mark spliced at the end of the code proper. -
#parts_suffix ⇒ Object
The dotted/dashed parts portion, each part with its own separator.
Methods inherited from Pubid::Ieee::Identifier
additional_identifier_classes, #code, #draft, #draft_month, from_hash, #initialize, #mr_number_with_part, #mr_publisher, #mr_type, #mr_year, parse, parse_single, #publisher, #to_hash
Methods inherited from Pubid::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_s, #to_slug, #to_supplement_s, #to_urn, #urn_supplement_type, #urn_type_code, #year
Constructor Details
This class inherits a constructor from Pubid::Ieee::Identifier
Instance Method Details
#code_end_index(code) ⇒ Object
Index at which the printed code ends and descriptive text begins.
The number is the first whitespace-delimited token after any stage word, so the code can never run past that token's end — which is what keeps the mark off a trailing edition/date phrase even when no CODE_END boundary matches inside the token.
95 96 97 98 99 100 |
# File 'lib/pubid/ieee/identifiers/iec_ieee_copublished.rb', line 95 def code_end_index(code) start = code[STAGE_PREFIX]&.length || 0 token_end = code.index(" ", start) || code.length boundary = code[start...token_end].index(CODE_END) boundary ? start + boundary : token_end end |
#copublished_number(mark = "") ⇒ Object
The printed IEC/IEEE number, rebuilt losslessly from the split columns (the renderer/urn read this). Not stored — number/parts/ separators/year fully describe it, so the verbatim string never bloats an index row.
36 37 38 39 40 41 42 |
# File 'lib/pubid/ieee/identifiers/iec_ieee_copublished.rb', line 36 def copublished_number(mark = "") return nil if number.to_s.empty? code = marked_code(mark) code += "#{year_sep}#{year}" if year code end |
#exclude(*args) ⇒ Object
The base IEEE #exclude already nils year/month/day; also reset the
year separator (a format sibling of the scalar year, per the CSA
lesson) so a date-less reference matches a :-dated form too.
105 106 107 108 109 110 111 |
# File 'lib/pubid/ieee/identifiers/iec_ieee_copublished.rb', line 105 def exclude(*args) result = super if args.intersect?(%i[year date]) && result.respond_to?(:year_sep=) result.year_sep = "-" end result end |
#marked_code(mark) ⇒ Object
number + #parts_suffix with the mark spliced at the end of the code
proper.
Some copublished references carry an edition, a colon year, a stage
word or a "- Redline" tail that the parser keeps inside
number/parts rather than in dedicated attributes; appending the
mark after all of it would print
IEC/IEEE 60076-16 Edition 2.0 2018-09™ instead of
IEC/IEEE 60076-16™ Edition 2.0 2018-09. Scanning the whole printed
code (not just the suffix) matters because the split point varies —
60802 Edition 1 lands in number, -16 Edition 2 in parts.
With the flag off mark is "" and this returns the code unchanged, so
the plain rendering is byte-identical by construction.
81 82 83 84 85 86 87 |
# File 'lib/pubid/ieee/identifiers/iec_ieee_copublished.rb', line 81 def marked_code(mark) code = "#{number}#{parts_suffix}" return code if mark.to_s.empty? at = code_end_index(code) "#{code[0...at]}#{mark}#{code[at..]}" end |
#parts_suffix ⇒ Object
The dotted/dashed parts portion, each part with its own separator.
45 46 47 |
# File 'lib/pubid/ieee/identifiers/iec_ieee_copublished.rb', line 45 def parts_suffix separators.zip(parts).map { |sep, part| "#{sep}#{part}" }.join end |