Class: Pubid::Gost::UrnGenerator
- Inherits:
-
Object
- Object
- Pubid::Gost::UrnGenerator
- Defined in:
- lib/pubid/gost/urn_generator.rb
Overview
Generates URN strings for GOST identifiers.
Format:
urn:gost:std:<number>[:<year>] (interstate)
urn:gost:std:r:<number>[:<year>] (Russian national)
urn:gost:std:r:<number>[:<year>] (IdenticalAdoption delegates to base)
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(identifier) ⇒ UrnGenerator
constructor
A new instance of UrnGenerator.
Constructor Details
#initialize(identifier) ⇒ UrnGenerator
Returns a new instance of UrnGenerator.
14 15 16 |
# File 'lib/pubid/gost/urn_generator.rb', line 14 def initialize(identifier) @identifier = identifier end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
12 13 14 |
# File 'lib/pubid/gost/urn_generator.rb', line 12 def identifier @identifier end |
Instance Method Details
#generate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pubid/gost/urn_generator.rb', line 18 def generate id = identifier while id.is_a?(Identifiers::Harmonized) || id.is_a?(Identifiers::IdenticalAdoption) id = id.base end return generate_for_standard(id) if standard?(id) raise ArgumentError, "Unknown GOST identifier class: #{identifier.class}" end |