Class: Pubid::Nist::Renderer

Inherits:
Renderers::Base show all
Defined in:
lib/pubid/nist/renderer.rb

Overview

Human-readable renderer for NIST identifiers.

NIST supports multiple output formats (:full, :long, :abbreviated, :short, :mr). Each series class defines public style methods (to_short_style, to_mr_style, etc.) with series-specific formatting logic, so this renderer delegates to those methods rather than reimplementing them.

Registered as the ‘:human` format in the NIST format registry and invoked via `render(format: :human, nist_format: :short)`.

Constant Summary

Constants inherited from Renderers::Base

Renderers::Base::SEMANTIC_SPLIT, Renderers::Base::TYPED_STAGE_CSS

Instance Method Summary collapse

Methods inherited from Renderers::Base

#initialize, render

Constructor Details

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

Instance Method Details

#render(context: nil, nist_format: nil, **_opts) ⇒ String

Render the identifier in the requested NIST format.

Parameters:

  • context (Object, nil) (defaults to: nil)

    rendering context (unused by NIST)

  • nist_format (Symbol, nil) (defaults to: nil)

    NIST output format (:full, :long, :abbreviated, :abbrev, :short, :mr). Defaults to :short.

Returns:

  • (String)

    formatted identifier string



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pubid/nist/renderer.rb', line 22

def render(context: nil, nist_format: nil, **_opts)
  id = @id

  effective_format = nist_format || :short
  effective_format = effective_format.to_sym if effective_format.is_a?(String)

  case effective_format
  when :full, :long
    id.public_send(:to_full_style)
  when :abbreviated, :abbrev
    id.public_send(:to_abbreviated_style)
  when :short
    id.public_send(:to_short_style)
  when :mr
    id.public_send(:to_mr_style)
  else
    id.public_send(:to_short_style)
  end
end