PubIDPubID

Library

API Reference

Top-Level Methods

Pubid::{Flavor}.parse(string)

Parse a publication identifier string into an identifier object.

id = Pubid::Iso.parse("ISO 9001:2015")
id = Pubid::Iec.parse("IEC 61131-3:2013")
id = Pubid::Nist.parse("NIST SP 800-53 Rev. 5")

Parameters:

Returns: Identifier object (flavor-specific class)

Raises: ParseError if the identifier cannot be parsed

Identifier Instance Methods

#to_s(**opts)

Render the identifier as a canonical string.

id = Pubid::Iso.parse("ISO 9001:2015")
id.to_s # => "ISO 9001:2015"

Options (varies by flavor):

#to_urn

Generate a URN representation.

id.to_urn # => "urn:iso:std:iso:9001:ed-5:en"

#to_h

Serialize to a Hash.

id.to_h # => { publisher: "ISO", number: "9001", ... }

#to_json

Serialize to JSON.

id.to_json # => '{"publisher":"ISO","number":"9001",...}'

Common Attributes

Most identifier objects expose these attributes:

Attribute Type Description
publisher String Publisher code
number String Document number
part String Part number
year Integer Publication year
edition Integer Edition number
stage Stage Development stage
language String Language code
type Type Document type

Flavor-Specific Classes

Each flavor has its own identifier classes under Pubid::{Flavor}::Identifiers::*.

For example, ISO has:

Registry

The Pubid::IdentifierRegistry provides lookup capabilities:

# Find by flavor and type
Pubid::IdentifierRegistry.find_by_type(:iso, :is)
# Get all identifiers for a flavor
Pubid::IdentifierRegistry.all_for_flavor(:iso)
# Export as JSON
Pubid::IdentifierRegistry.to_json

See Also