Class: Pubid::Asme::Renderer
- Inherits:
-
Renderers::Base
- Object
- Renderers::Base
- Pubid::Asme::Renderer
- Defined in:
- lib/pubid/asme/renderer.rb
Overview
Human-readable renderer for ASME identifiers.
Produces strings like:
"ASME B16.5-2020"
"CSA B44.10/ASME A17.10"
"ASME BPVC III.1.NB-2023"
"ASME PTC 4-2013"
The renderer is registered as the ‘:human` format in the ASME format registry and invoked via `render(format: :human)`.
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
Constructor Details
This class inherits a constructor from Pubid::Renderers::Base
Instance Method Details
#render(context: nil, **opts) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pubid/asme/renderer.rb', line 16 def render(context: nil, **opts) id = @id parts = [] if id.first_publisher && id.first_code # CSA B44.10/ASME A17.10 or API 579-2/ASME PTB-14 format parts << id.first_publisher parts << id.first_code parts << "/#{id.second_publisher}" if id.second_publisher parts << id.code.to_s if id.code && id.code.to_s != "" elsif id.joint_publisher # ISO/ASME or ASME/ANS format parts << id.joint_publisher parts << id.code.to_s if id.code && id.code.to_s != "" else # Standard ASME format parts << id.publisher if id.publisher parts << id.code.to_s if id.code end result = parts.join(" ") if id.ptc_suffix result += " #{id.ptc_suffix}" end if id.csa_number result += "/CSA #{id.csa_number}" end if id.handbook result += " Handbook" end if id.draft_year result += "-#{id.draft_year}" elsif id.year result += "-#{id.year}" end result += " #{id.parenthetical_revision}" if id.parenthetical_revision result += " (#{id.language})" if id.language result += " (#{id.reaffirmation})" if id.reaffirmation result += " #{id.revision_note}" if id.revision_note # Normalize all em-dashes and en-dashes to regular dash result.gsub(/[–—]/, "-") end |