Class: Pubid::Xsf::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Xsf::Identifier
- Defined in:
- lib/pubid/xsf/identifier.rb
Overview
Base class for every XSF identifier AND the flavor's parse/create entry point — mirrors Pubid::Jis::Identifier. The single concrete type (Pubid::Xsf::Identifiers::Xep) descends from this class, so a parsed XSF id is an instance of Pubid::Xsf::Identifier.
Direct Known Subclasses
Constant Summary collapse
- XSF_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:xsf:xep" => "Pubid::Xsf::Identifiers::Xep", }.freeze
- PUBLISHER =
Publisher name. A plain constant (not a
publishermethod) so it does not shadow the inherited lutamlpublisherattribute, which would otherwise fail serialization type validation. XSF never prints its publisher name in an identifier — the leading token is "XEP". "XSF"
Instance Attribute Summary collapse
-
#with_publisher ⇒ Object
readonly
Returns the value of attribute with_publisher.
Class Method Summary collapse
-
.parse(identifier) ⇒ Identifier
Parse an XSF identifier string into an identifier object.
Instance Method Summary collapse
-
#to_s(with_publisher: true, **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?, #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.
33 34 35 |
# File 'lib/pubid/xsf/identifier.rb', line 33 def with_publisher @with_publisher end |
Class Method Details
.parse(identifier) ⇒ Identifier
Parse an XSF identifier string into an identifier object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pubid/xsf/identifier.rb', line 50 def self.parse(identifier) 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 XSF identifier '#{identifier}': #{e.}" end |
Instance Method Details
#to_s(with_publisher: true, **opts) ⇒ Object
Basic string representation. Delegates to renderer; with_publisher: false yields the bare number.
37 38 39 40 |
# File 'lib/pubid/xsf/identifier.rb', line 37 def to_s(with_publisher: true, **opts) @with_publisher = with_publisher render(format: :human, **opts) end |