Module: Pubid::Iho::Identifier
- Defined in:
- lib/pubid/iho/identifier.rb
Overview
Entry point for parsing IHO identifiers.
Class Method Summary collapse
-
.create(type: nil, **opts) ⇒ Object
Factory that builds an IHO identifier from a hash of primitives.
-
.parse(identifier) ⇒ Pubid::Iho::Identifiers::Base
Parse an IHO identifier string into an identifier object.
Class Method Details
.create(type: nil, **opts) ⇒ Object
Factory that builds an IHO identifier from a hash of primitives.
IHO identifiers are simpler than ISO/IEC: attributes are plain strings (no Component wrapping), so coercion just calls #to_s.
Dispatch:
* `type:` accepts the type key (`:standard`, `:publication`,
`:miscellaneous`, `:bibliographic`, `:circular_letter`) or
the IHO series letter (`"S"`, `"P"`, `"M"`, `"B"`, `"C"`).
* Default is {Identifiers::Standard}.
32 33 34 35 |
# File 'lib/pubid/iho/identifier.rb', line 32 def self.create(type: nil, **opts) klass = resolve_create_class(type) klass.new(**coerce_create_attrs(opts)) end |
.parse(identifier) ⇒ Pubid::Iho::Identifiers::Base
Parse an IHO identifier string into an identifier object
11 12 13 14 15 16 |
# File 'lib/pubid/iho/identifier.rb', line 11 def self.parse(identifier) parsed = Parser.parse(identifier) Builder.build(parsed) rescue Parslet::ParseFailed => e raise "Failed to parse IHO identifier '#{identifier}': #{e.}" end |