Class: Pubid::Renderers::DirectivesRenderer

Inherits:
HumanReadable show all
Defined in:
lib/pubid/renderers/directives_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
# File 'lib/pubid/renderers/directives_renderer.rb', line 6

def render(context:, with_edition: false)
  parts = []
  parts << render_publisher_portion(context)
  num_port = render_number_portion(context)

  if num_port && !num_port.empty?
    if num_port.start_with?(":")
      result = parts.compact.join(" ") + num_port
    else
      parts << num_port
      result = parts.compact.join(" ")
    end
  else
    result = parts.compact.join(" ")
  end

  result << " #{render_edition_portion(context)}" if with_edition && @id.edition&.number
  result << render_language_portion(context, with_edition: with_edition)
  result
end