Module: Pubid::Jis::Identifier

Defined in:
lib/pubid/jis/identifier.rb

Class Method Summary collapse

Class Method Details

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

Factory mirroring pubid 1.x’s ‘Pubid::Jis::Identifier.create` API.

JIS uses a different attribute schema from most flavors — ‘series` (single letter A–Z), `number` (integer), `parts` (integer collection), `year` (integer), `language`. Publisher is hardcoded “JIS” on the instance and not a constructor kwarg; supplying `:publisher` is silently ignored.

Type dispatch: :jis → Standard, :tr → TechnicalReport, :ts → TechnicalSpecification. Default → Standard.



27
28
29
30
31
32
33
34
# File 'lib/pubid/jis/identifier.rb', line 27

def self.create(type: nil, **opts)
  klass = if type
            safe_locate_klass(type) || Identifiers::Standard
          else
            Identifiers::Standard
          end
  klass.new(**coerce_create_attrs(opts))
end

.parse(identifier) ⇒ Identifiers::Base

Parse a JIS identifier string into an identifier object

Parameters:

  • identifier (String)

    The JIS identifier string to parse

Returns:

Raises:

  • (Parslet::ParseFailed)

    If parsing fails



10
11
12
13
14
15
# File 'lib/pubid/jis/identifier.rb', line 10

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