Module: Pubid::PrefixesSupport
- Included in:
- Amca, Ansi, Api, Ashrae, Asme, Astm, Bsi, Ccsds, CenCenelec, Cie, Csa, Etsi, Iala, Idf, Iec, Ieee, Iho, Iso, Itu, Jcgm, Jis, Nist, Oiml, Plateau, Sae
- Defined in:
- lib/pubid/prefixes_support.rb
Overview
Mixin providing the uniform, static prefixes class method that every
registered flavor exposes. relaton uses this to build a global prefix
register that routes a printed reference string (e.g. "DD 1234",
"ISO/IEC 8802") to the flavor(s) that own it.
A flavor +extend+s this module and defines a frozen PREFIXES array holding
only its own leading tokens. Joint / co-publication tokens are injected
centrally from JOINT_PREFIXES so that a co-published prefix
(e.g. "ISO/IEC") is listed symmetrically by every co-publisher without
being duplicated by hand in two files.
Inclusion policy
prefixes returns the set of leading identifier prefix tokens — the
tokens a printed identifier can start with such that the string belongs to
this SDO. Concretely it INCLUDES:
- publisher prefixes (e.g.
ISO,IEC,NIST,NBS,BS,BSI); - leading series/type tokens that can begin a printed reference on their own (e.g. BSI +DD+/+PD+, NIST +FIPS+/+SP+);
- joint / co-publication forms (e.g.
ISO/IEC,ISO/IEC/IEEE). It EXCLUDES: - pure sub-series that never appear without a publisher prefix;
- dangerously-ambiguous single letters (e.g. BSI aerospace +A+/+B+/+C+), which would cause false routing.
Instance Method Summary collapse
-
#prefix_flavor_key ⇒ Symbol
The registry key for this flavor, derived from the module name (e.g.
Pubid::CenCenelec=>:cen_cenelec). -
#prefixes ⇒ Array<String>
The static set of leading prefix tokens this flavor recognizes.
Instance Method Details
#prefix_flavor_key ⇒ Symbol
The registry key for this flavor, derived from the module name
(e.g. Pubid::CenCenelec => :cen_cenelec). Used to look this flavor up
in JOINT_PREFIXES and to label it in Pubid.prefix_flavors.
46 47 48 49 |
# File 'lib/pubid/prefixes_support.rb', line 46 def prefix_flavor_key name.split("::").last .gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym end |
#prefixes ⇒ Array<String>
The static set of leading prefix tokens this flavor recognizes.
Static: callable without parsing any identifier string. Strings are
returned in canonical case exactly as printed (e.g. "BS EN ISO",
"ISO/IEC"); consumers fold case themselves.
35 36 37 38 39 |
# File 'lib/pubid/prefixes_support.rb', line 35 def prefixes own = const_defined?(:PREFIXES) ? const_get(:PREFIXES) : [] joint = Pubid::JOINT_PREFIXES.fetch(prefix_flavor_key, []) (own + joint).uniq.freeze end |