Module: Pubid::Iec

Extended by:
PrefixesSupport
Defined in:
lib/pubid/iec.rb,
lib/pubid/iec/parser.rb,
lib/pubid/iec/builder.rb,
lib/pubid/iec/renderer.rb,
lib/pubid/iec/components.rb,
lib/pubid/iec/identifier.rb,
lib/pubid/iec/urn_parser.rb,
lib/pubid/iec/identifiers.rb,
lib/pubid/iec/urn_generator.rb,
lib/pubid/iec/components/code.rb,
lib/pubid/iec/rendering_style.rb,
lib/pubid/iec/components/sheet.rb,
lib/pubid/iec/identifiers/base.rb,
lib/pubid/iec/identifiers/guide.rb,
lib/pubid/iec/single_identifier.rb,
lib/pubid/iec/components/trf_info.rb,
lib/pubid/iec/components/publisher.rb,
lib/pubid/iec/components/vap_suffix.rb,
lib/pubid/iec/identifiers/amendment.rb,
lib/pubid/iec/supplement_identifier.rb,
lib/pubid/iec/identifiers/corrigendum.rb,
lib/pubid/iec/identifiers/white_paper.rb,
lib/pubid/iec/identifiers/vap_identifier.rb,
lib/pubid/iec/identifiers/sheet_identifier.rb,
lib/pubid/iec/identifiers/technical_report.rb,
lib/pubid/iec/identifiers/test_report_form.rb,
lib/pubid/iec/identifiers/working_document.rb,
lib/pubid/iec/identifiers/technology_report.rb,
lib/pubid/iec/identifiers/fragment_identifier.rb,
lib/pubid/iec/identifiers/interpretation_sheet.rb,
lib/pubid/iec/identifiers/operational_document.rb,
lib/pubid/iec/components/consolidated_amendment.rb,
lib/pubid/iec/identifiers/conformity_assessment.rb,
lib/pubid/iec/identifiers/international_standard.rb,
lib/pubid/iec/identifiers/component_specification.rb,
lib/pubid/iec/identifiers/consolidated_identifier.rb,
lib/pubid/iec/identifiers/technical_specification.rb,
lib/pubid/iec/identifiers/systems_reference_document.rb,
lib/pubid/iec/identifiers/publicly_available_specification.rb,
lib/pubid/iec/identifiers/societal_technology_trend_report.rb

Defined Under Namespace

Modules: Components, DelegatedFieldSuppression, Identifiers Classes: Builder, Identifier, Parser, RefDated, RefDatedLong, RefNumLong, RefNumShort, RefUndated, RefUndatedLong, Renderer, RenderingStyle, SingleIdentifier, SupplementIdentifier, UrnGenerator, UrnParser

Constant Summary collapse

PREFIXES =

Sourced from the parser's publisher list (Components::Publisher::PUBLISHERS) minus the joint "ISO/IEC", which is contributed symmetrically via Pubid::JOINT_PREFIXES (along with IEC/ISO and ISO/IEC/IEEE).

(Components::Publisher::PUBLISHERS.keys - ["ISO/IEC"]).freeze

Class Method Summary collapse

Methods included from PrefixesSupport

prefix_flavor_key, prefixes

Class Method Details

.all_typed_stagesObject



48
49
50
51
52
53
54
55
56
# File 'lib/pubid/iec.rb', line 48

def self.all_typed_stages
  @all_typed_stages ||= identifier_types.flat_map do |klass|
    if klass.const_defined?(:TYPED_STAGES)
      klass.const_get(:TYPED_STAGES)
    else
      []
    end
  end
end

.identifier_typesObject



41
42
43
44
45
46
# File 'lib/pubid/iec.rb', line 41

def self.identifier_types
  @identifier_types ||= Identifiers.constants
    .filter_map { |c| begin; Identifiers.const_get(c); rescue NameError; nil; end }
    .select { |c| c.is_a?(Class) && c.singleton_methods(false).include?(:type) }
    .select { |c| begin; c.type.is_a?(Hash); rescue NotImplementedError; false; end }
end

.locate_stage(abbr) ⇒ Object



62
63
64
65
# File 'lib/pubid/iec.rb', line 62

def self.locate_stage(abbr)
  abbr_str = abbr.to_s.upcase
  all_typed_stages.find { |s| s.abbr.any? { |a| a.to_s.upcase == abbr_str } }
end

.locate_type(code) ⇒ Object



58
59
60
# File 'lib/pubid/iec.rb', line 58

def self.locate_type(code)
  identifier_types.find { |t| t.type[:key].to_s == code.to_s }
end

.parse(identifier_string) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/pubid/iec.rb', line 25

def self.parse(identifier_string)
  if identifier_string.length > Pubid::MAX_INPUT_LENGTH
    raise ArgumentError, Pubid::INPUT_TOO_LONG_MESSAGE
  end

  parsed = Parser.new.parse(identifier_string)
  Builder.new.build(parsed)
end

.parse_urn(urn) ⇒ Object



34
35
36
# File 'lib/pubid/iec.rb', line 34

def self.parse_urn(urn)
  UrnParser.parse(urn)
end