Class: Pubid::Iso::Renderer::Urn

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

Direct Known Subclasses

UrnDir, UrnTc

Constant Summary collapse

STAGES =
{ PWI: 0,
NP: 10,
AWI: 20,
WD: 20.20,
CD: 30,
DIS: 40,
FDIS: 50,
PRF: 50,
IS: 60 }.freeze

Instance Method Summary collapse

Instance Method Details

#prerender(with_edition: true, **args) ⇒ Object



13
14
15
16
# File 'lib/pubid/iso/renderer/urn.rb', line 13

def prerender(with_edition: true, **args)
  @params[:type_stage] = @params.slice(:stage, :type) if @params[:stage] || @params[:type]
  super
end

#render(with_edition: true, **args) ⇒ Object

Render identifier

Parameters:

  • with_edition (Boolean) (defaults to: true)

    include edition in output

See Also:

  • for another options


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

def render(with_edition: true, **args)
  # copy type from typed stage
  @params[:type] = @params[:typed_stage].type if @params[:typed_stage] && @params[:typed_stage].type
  super(**args.merge({ with_edition: with_edition }))
end

#render_identifier(params) ⇒ Object



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

def render_identifier(params)
  render_base(params) + "%{typed_stage}"\
  "%{corrigendum_stage}%{iteration}%{edition}%{amendments}%{corrigendums}" % params
end

#render_iteration(iteration, _opts, params) ⇒ Object

def render_stage(stage, _opts, params)

":stage-#{stage.harmonized_code}"

end



39
40
41
# File 'lib/pubid/iso/renderer/urn.rb', line 39

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

#render_type(type, _, _) ⇒ Object



43
44
45
# File 'lib/pubid/iso/renderer/urn.rb', line 43

def render_type(type, _, _)
  ":#{type.to_s.downcase}" unless type == :is
end

#render_typed_stage(typed_stage, _opts, _params) ⇒ Object



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

def render_typed_stage(typed_stage, _opts, _params)
  ":stage-#{typed_stage.stage.harmonized_code}" if typed_stage.stage
end

#render_year(year, _opts, _params) ⇒ Object



47
48
49
# File 'lib/pubid/iso/renderer/urn.rb', line 47

def render_year(year, _opts, _params)
  ":#{year}"
end