Class: Pubid::Oasis::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Oasis::Identifier
- Defined in:
- lib/pubid/oasis/identifier.rb
Overview
Base class for every OASIS identifier AND the flavor's parse/create entry
point. The single concrete type Identifiers::Standard descends from this
class, so a parsed OASIS id is an instance of Pubid::Oasis::Identifier.
OASIS identifiers are free-form slugs with an inconsistent internal
structure (spec name + version + approval stage + part + label, in
varying order). To guarantee a lossless round-trip we always keep the
exact printed slug verbatim in original (which alone drives to_s); the
remaining component fields are a best-effort decomposition for relaton
querying and can be nil without ever affecting the rendered string.
Direct Known Subclasses
Constant Summary collapse
- OASIS_TYPE_MAP =
Polymorphic type map for lutaml::Model key_value (de)serialization: maps the subclass's polymorphic_name to its class name so a stored hash rebuilds the correct identifier type via from_hash.
{ "pubid:oasis:standard" => "Pubid::Oasis::Identifiers::Standard", }.freeze
- PUBLISHER =
Publisher is always "OASIS". A plain constant (not a
publishermethod) so it doesn't shadow the inherited lutamlpublisherattribute, which would otherwise fail serialization type validation. "OASIS"
Instance Attribute Summary collapse
-
#with_publisher ⇒ Object
readonly
Returns the value of attribute with_publisher.
Class Method Summary collapse
-
.parse(identifier) ⇒ Identifier
Parse an OASIS identifier string into an identifier object.
Instance Method Summary collapse
Methods inherited from 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_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
Instance Attribute Details
#with_publisher ⇒ Object (readonly)
Returns the value of attribute with_publisher.
54 55 56 |
# File 'lib/pubid/oasis/identifier.rb', line 54 def with_publisher @with_publisher end |
Class Method Details
.parse(identifier) ⇒ Identifier
Parse an OASIS identifier string into an identifier object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pubid/oasis/identifier.rb', line 68 def self.parse(identifier) # Reject pathological inputs before they reach the parser # (CodeQL rb/polynomial-redos barrier — inline .length by design). if identifier.length > Pubid::MAX_INPUT_LENGTH raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE end parsed = Parser.parse(identifier) Builder.build(parsed) rescue Parslet::ParseFailed => e raise "Failed to parse OASIS identifier '#{identifier}': #{e.}" end |
Instance Method Details
#to_s(with_publisher: true, **opts) ⇒ Object
56 57 58 59 |
# File 'lib/pubid/oasis/identifier.rb', line 56 def to_s(with_publisher: true, **opts) @with_publisher = with_publisher render(format: :human, **opts) end |