Class: Pubid::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/pubid/registry.rb

Class Method Summary collapse

Class Method Details

.parse(*args) ⇒ Object

Raises:

  • (Pubid::Core::Errors::ParseError)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pubid/registry.rb', line 4

def parse(*args)
  modules = [Pubid::Iso,
             Pubid::Ieee,
             Pubid::Nist,
             Pubid::Iec,
             Pubid::Cen,
             Pubid::Bsi,
             Pubid::Ccsds,
             Pubid::Itu,
             Pubid::Jis]
  modules.each do |mod|
    module_identifier = Kernel.const_get("#{mod}::Identifier")
    return module_identifier.parse(*args) if module_identifier.parseable?(*args)
  end

  # Go through each module to try to parse unknown prefix
  modules.each do |mod|
    return Kernel.const_get("#{mod}::Identifier").parse(*args)
  rescue Pubid::Core::Errors::ParseError
    next
  end

  raise Pubid::Core::Errors::ParseError, "cannot find module to parse #{args}"
end