Class: Pubid::Astm::Identifier

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

Constant Summary collapse

TYPE_KEY_TO_KLASS =

Factory that builds an ASTM identifier from a hash of primitives. Default is Pubid::Astm::Identifiers::Standard.

ASTM’s Code Component has :letter (single letter A–Z) + :number (rest); ‘.create` accepts either an already-split pair or a combined `:code` string which it splits at the first digit.

{
  standard:           "Standard",
  adjunct:            "Adjunct",
  manual:             "Manual",
  monograph:          "Monograph",
  research_report:    "ResearchReport",
  technical_report:   "TechnicalReport",
  data_series:        "DataSeries",
  iso_dual_published: "IsoDualPublished",
  work_in_progress:   "WorkInProgress",
}.freeze

Class Method Summary collapse

Methods inherited from Identifier

#base_identifier, #eql?, #exclude, #hash, #initialize, #mr_number, #mr_number_with_part, #mr_part, #mr_publisher, #mr_type, #mr_year, #new_edition_of?, polymorphic_name, #render, #resolve_urn_generator, #root, #to_mr_string, #to_s, #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

.create(type: nil, **opts) ⇒ Object



32
33
34
35
# File 'lib/pubid/astm/identifier.rb', line 32

def self.create(type: nil, **opts)
  klass = resolve_create_class(type)
  klass.new(**coerce_create_attrs(opts, klass: klass))
end

.parse(str) ⇒ Object



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

def self.parse(str)
  parser = Parser.new
  builder = Builder.new

  parsed = parser.parse(str)
  builder.build(parsed)
end