Class: Pubid::Sae::Identifier

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

Class Method Summary collapse

Class Method Details

.create(**opts) ⇒ Object

Factory that builds a SAE identifier from a hash of primitives. SAE has only one identifier class (Pubid::Sae::Identifiers::Base); ‘:type` is data (the document-type abbreviation: “J”, “AS”, “ARP”, “AMS”, “AIR”, “MA”) rather than a class-dispatch key.



17
18
19
# File 'lib/pubid/sae/identifier.rb', line 17

def self.create(**opts)
  Identifiers::Base.new(**coerce_create_attrs(opts))
end

.parse(input) ⇒ Object



6
7
8
9
10
11
# File 'lib/pubid/sae/identifier.rb', line 6

def self.parse(input)
  parsed = Parser.parse(input)
  Builder.build(parsed)
rescue Parslet::ParseFailed => e
  raise "Failed to parse SAE identifier: #{input}\n#{e.message}"
end