Class: Pubid::Iso::Renderer::UrnDir

Inherits:
Urn
  • Object
show all
Defined in:
lib/pubid/iso/renderer/urn-dir.rb

Constant Summary

Constants inherited from Urn

Pubid::Iso::Renderer::Urn::STAGES

Instance Method Summary collapse

Methods inherited from Urn

#prerender, #render, #render_iteration, #render_part, #render_prefix, #render_stage, #render_type, #render_year

Instance Method Details

#render_dirtype(dirtype, _opts, _params) ⇒ Object



28
29
30
# File 'lib/pubid/iso/renderer/urn-dir.rb', line 28

def render_dirtype(dirtype, _opts, _params)
  ":#{dirtype.downcase}"
end

#render_identifier(params) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pubid/iso/renderer/urn-dir.rb', line 6

def render_identifier(params)
  res = ("urn:iso:doc:%{publisher}%{copublisher}:dir%{dirtype}%{number}%{year}%{supplement}" % params)

  if params.key?(:joint_document)
    if params[:joint_document].is_a?(Pubid::Iso::Identifier::Supplement)
      joint_params = params[:joint_document].to_h(deep: false)
      res += ":#{joint_params[:base].publisher.downcase}:sup:%{year}" % joint_params
    else
      joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
      joint_params.default = ""
      res += (":%{publisher}%{copublisher}%{dirtype}%{number}%{supplement}" % joint_params)
    end

  end

  res
end

#render_number(number, _opts, _params) ⇒ Object



24
25
26
# File 'lib/pubid/iso/renderer/urn-dir.rb', line 24

def render_number(number, _opts, _params)
  ":#{number}"
end

#render_supplement(supplement, _opts, _params) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/pubid/iso/renderer/urn-dir.rb', line 32

def render_supplement(supplement, _opts, _params)
  if supplement.publisher && supplement.publisher != ""
    ":sup:#{supplement.publisher.downcase}"
  else
    ":sup"
  end + (supplement.year && ":#{supplement.year}" || "") +
    (supplement.edition && ":ed-#{supplement.edition}" || "")
end