Module: Pubid::Rendering::Stage

Included in:
Base
Defined in:
lib/pubid/rendering/stage.rb

Instance Method Summary collapse

Instance Method Details

#render_stage(stage, type = nil, has_copublisher: false, **_options) ⇒ String

Render stage and type abbreviations

Parameters:

  • stage (Components::Stage)

    stage component

  • type (Components::Type) (defaults to: nil)

    type component

  • has_copublisher (Boolean) (defaults to: false)

    whether copublisher exists

  • options (Hash)

    rendering options

Returns:

  • (String)

    formatted stage/type string



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pubid/rendering/stage.rb', line 12

def render_stage(stage, type = nil, has_copublisher: false, **_options)
  result = ""

  if stage&.abbr
    separator = has_copublisher ? " " : "/"
    result += "#{separator}#{stage.abbr}"
  end

  if type&.abbr && type.abbr != default_type_abbr
    result += type_separator(has_copublisher, result) + type.abbr
  end

  result
end