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_all_parts, #render_iteration, #render_part, #render_prefix, #render_stage, #render_type, #render_year

Instance Method Details

#render_dirtype(dirtype, _opts, _params) ⇒ Object



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

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

#render_identifier(params) ⇒ Object

rubocop:disable Metrics/AbcSize,Metrics/MethodLength



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

def render_identifier(params) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  res = ("urn:iso:doc:%<publisher>s%<copublisher>s:dir%<dirtype>s%<number>s%<year>s%<supplement>s" % 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>s" % joint_params
    else
      joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
      joint_params.default = ""
      res += (":%<publisher>s%<copublisher>s%<dirtype>s%<number>s%<supplement>s" % joint_params)
    end

  end

  res + params[:all_parts]
end

#render_number(number, _opts, _params) ⇒ Object



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

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

#render_supplement(supplement, _opts, _params) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity



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

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