Class: Pubid::Gb::Identifier
- Inherits:
-
Identifier
- Object
- Lutaml::Model::Serializable
- Identifier
- Pubid::Gb::Identifier
- Defined in:
- lib/pubid/gb/identifier.rb
Overview
Base class for every Chinese Standard identifier AND the flavor's parse/create entry point. Concrete types under Pubid::Gb::Identifiers descend from this class, so a parsed GB id is always an instance of Pubid::Gb::Identifier.
Direct Known Subclasses
Constant Summary collapse
- GB_TYPE_MAP =
Polymorphic type map for lutaml key_value (de)serialization.
{ "pubid:gb:standard" => "Pubid::Gb::Identifiers::Standard", }.freeze
- PUBLISHER =
"CN"
Class Method Summary collapse
-
.parse(identifier) ⇒ Pubid::Gb::Identifier
Parse a Chinese Standard identifier string.
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
Class Method Details
.parse(identifier) ⇒ Pubid::Gb::Identifier
Parse a Chinese Standard identifier string.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pubid/gb/identifier.rb', line 52 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 Chinese Standard identifier '#{identifier}': #{e.}" end |
Instance Method Details
#to_s(**opts) ⇒ Object
45 46 47 |
# File 'lib/pubid/gb/identifier.rb', line 45 def to_s(**opts) render(format: :human, **opts) end |