Class: Pubid::Core::Renderer::Urn

Inherits:
Base
  • Object
show all
Defined in:
lib/pubid/core/renderer/urn.rb

Constant Summary

Constants inherited from Base

Base::LANGUAGES

Instance Attribute Summary

Attributes inherited from Base

#params

Instance Method Summary collapse

Methods inherited from Base

#initialize, #prerender, #prerender_params, #render, #render_base_identifier, #render_supplement, #render_year

Constructor Details

This class inherits a constructor from Pubid::Core::Renderer::Base

Instance Method Details

#render_amendments(amendments, _opts, _params) ⇒ Object



32
33
34
# File 'lib/pubid/core/renderer/urn.rb', line 32

def render_amendments(amendments, _opts, _params)
  amendments&.map(&:render_urn)&.join || ""
end

#render_base(params) ⇒ Object



4
5
6
# File 'lib/pubid/core/renderer/urn.rb', line 4

def render_base(params)
  "urn:iso:std:%{publisher}%{copublisher}%{type}:%{number}%{part}" % params
end

#render_copublisher(copublisher, _opts, _params) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/pubid/core/renderer/urn.rb', line 16

def render_copublisher(copublisher, _opts, _params)
  return "-#{copublisher.to_s.downcase}" unless copublisher.is_a?(Array)

  copublisher.map(&:to_s).sort.map do |copublisher|
    "-#{copublisher.downcase}"
  end.join
end

#render_corrigendum_stage(stage, opts, params) ⇒ Object



45
46
47
# File 'lib/pubid/core/renderer/urn.rb', line 45

def render_corrigendum_stage(stage, opts, params)
  render_stage(stage, opts, params)
end

#render_corrigendums(corrigendums, _opts, _params) ⇒ Object



36
37
38
# File 'lib/pubid/core/renderer/urn.rb', line 36

def render_corrigendums(corrigendums, _opts, _params)
  corrigendums&.map(&:render_urn)&.join || ""
end

#render_edition(edition, _opts, _params) ⇒ Object



24
25
26
# File 'lib/pubid/core/renderer/urn.rb', line 24

def render_edition(edition, _opts, _params)
  ":ed-#{edition}"
end

#render_identifier(params) ⇒ Object



8
9
10
# File 'lib/pubid/core/renderer/urn.rb', line 8

def render_identifier(params)
  render_base(params)
end

#render_iteration(iteration, _opts, params) ⇒ Object



49
50
51
# File 'lib/pubid/core/renderer/urn.rb', line 49

def render_iteration(iteration, _opts, params)
  ".v#{iteration}" if params[:stage]
end

#render_language(language, _opts, _params) ⇒ Object



40
41
42
# File 'lib/pubid/core/renderer/urn.rb', line 40

def render_language(language, _opts, _params)
  ":#{language}"
end

#render_part(part, _opts, _params) ⇒ Object



53
54
55
# File 'lib/pubid/core/renderer/urn.rb', line 53

def render_part(part, _opts, _params)
  ":-#{part}"
end

#render_publisher(publisher, _opts, _params) ⇒ Object



12
13
14
# File 'lib/pubid/core/renderer/urn.rb', line 12

def render_publisher(publisher, _opts, _params)
  publisher.downcase
end

#render_type(type, _, _) ⇒ Object



28
29
30
# File 'lib/pubid/core/renderer/urn.rb', line 28

def render_type(type, _, _)
  ":#{type.downcase}"
end