Class: Metanorma::Html::Renderers::PubidRenderer
- Inherits:
-
Object
- Object
- Metanorma::Html::Renderers::PubidRenderer
- Defined in:
- lib/metanorma/html/renderers/pubid_renderer.rb
Constant Summary collapse
- FLAVOR_PUBID_MAP =
{ "IsoDocument" => :"Pubid::Iso", "IecDocument" => :"Pubid::Iec", "IeeeDocument" => :"Pubid::Ieee", "IhoDocument" => :"Pubid::Iho", "ItuDocument" => :"Pubid::Ithu", "OimlDocument" => :"Pubid::Oiml", }.freeze
Instance Method Summary collapse
-
#initialize(coordinator) ⇒ PubidRenderer
constructor
A new instance of PubidRenderer.
- #parse_pubid(docidentifier_string) ⇒ Object
- #pubid_to_html(identifier) ⇒ Object
Constructor Details
#initialize(coordinator) ⇒ PubidRenderer
Returns a new instance of PubidRenderer.
16 17 18 |
# File 'lib/metanorma/html/renderers/pubid_renderer.rb', line 16 def initialize(coordinator) @coordinator = coordinator end |
Instance Method Details
#parse_pubid(docidentifier_string) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metanorma/html/renderers/pubid_renderer.rb', line 20 def parse_pubid(docidentifier_string) return nil if docidentifier_string.nil? || docidentifier_string.strip.empty? flavor_module = resolve_pubid_module return nil unless flavor_module flavor_module.parse(docidentifier_string) rescue StandardError nil end |
#pubid_to_html(identifier) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/metanorma/html/renderers/pubid_renderer.rb', line 31 def pubid_to_html(identifier) return nil unless identifier @coordinator.render_liquid("_pubid_identifier.html.liquid", { "publisher" => identifier.publisher ? escape_html(identifier.publisher) : nil, "number" => identifier.number ? escape_html(identifier.number.to_s) : nil, "date" => identifier.date ? escape_html(identifier.date.to_s) : nil, }) end |