Class: Pubid::CenCenelec::Identifier

Inherits:
Identifier
  • Object
show all
Defined in:
lib/pubid/cen_cenelec/identifier.rb

Overview

Common base class for all CEN/CENELEC identifiers. CEN/CENELEC has a split hierarchy — some concrete types descend from Identifiers::Base, others from SingleIdentifier — so this class is the shared parent of BOTH, making every CEN/CENELEC identifier is_a?(Pubid::CenCenelec::Identifier) natively (and giving them the shared polymorphic from_hash). No facade needed.

Class 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_s, #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) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/pubid/cen_cenelec/identifier.rb', line 11

def self.parse(identifier)
  if identifier.length > Pubid::MAX_INPUT_LENGTH
    raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
  end

  parsed = Parser.parse(identifier)
  Builder.new.build(parsed)
rescue Parslet::ParseFailed => e
  raise "Failed to parse CEN identifier '#{identifier}': #{e.message}"
end