Class: Pubid::Renderers::SupplementRenderer

Inherits:
HumanReadable show all
Defined in:
lib/pubid/renderers/supplement_renderer.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, render

Constructor Details

This class inherits a constructor from Pubid::Renderers::Base

Instance Method Details

#render(context:, with_edition: false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pubid/renderers/supplement_renderer.rb', line 6

def render(context:, with_edition: false)
  parts = []

  base_str = @id.base_identifier.to_s(
    with_edition: with_edition,
    stage_format_long: context.stage_format_long,
    with_date: context.with_date,
  )

  stage_str = @id.typed_stage.render(context:)
  parts << "#{base_str}/#{stage_str}"

  num_port = render_number_portion(context)
  if num_port && !num_port.empty? && !num_port.start_with?(":")
    parts << (stage_str.end_with?(".") ? "" : " ")
  end
  parts << num_port

  parts << " #{render_edition_portion(context)}" if with_edition && @id.edition&.number
  if @id.languages&.any?
    parts << render_language_portion(context,
                                     with_edition: with_edition)
  end
  parts.compact.join
end