Class: Pubid::Calconnect::Renderer

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

Overview

Human-readable renderer for CalConnect identifiers.

Produces the canonical printed form, e.g.:

"CC 18011:2018"
"CC/DIR 10006:2019"
"CC/WD 51017:2024-07-23"
"DIR 10006:2019"          (only when with_publisher: false)

Registered as the :human format in the CalConnect format registry and invoked via render(format: :human).

Constant Summary collapse

PUBLISHER =
"CC"

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(**_opts) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/pubid/calconnect/renderer.rb', line 18

def render(**_opts)
  id = @id
  prefix = if with_publisher?(id)
             id.series ? "#{PUBLISHER}/#{id.series} " : "#{PUBLISHER} "
           else
             id.series ? "#{id.series} " : ""
           end
  date = id.date_string
  "#{prefix}#{id.number}#{":#{date}" if date}"
end