Sha256: 24dcb6be00b707324de5aec5b626cf166a56326928916f7c38d13ee0398f8d1c

Contents?: true

Size: 1.49 KB

Versions: 2

Compression:

Stored size: 1.49 KB

Contents

require "isodoc"

module IsoDoc
  module BIPM
    class Metadata < IsoDoc::Generic::Metadata
      def configuration
        Metanorma::BIPM.configuration
      end

      def title(isoxml, _out)
        lang1 = @lang == "fr" ? "fr" : "en"
        lang2 = @lang == "fr" ? "en" : "fr"
        set(:doctitle, @c.encode(isoxml&.at(
          ns("//bibdata/title[@type='main'][@language='#{lang1}']"))&.text || ""))
        set(:docsubtitle, @c.encode(isoxml&.at(
          ns("//bibdata/title[@type='main'][@language='#{lang2}']"))&.text || ""))
        set(:appendixtitle, @c.encode(isoxml&.at(
          ns("//bibdata/title[@type='appendix'][@language='#{lang1}']"))&.text || ""))
        set(:appendixsubtitle, @c.encode(isoxml&.at(
          ns("//bibdata/title[@type='appendix'][@language='#{lang2}']"))&.text || ""))
      end

      def status_print(status)
        return "Procès-Verbal" if status == "procès-verbal"
        return "CIPM-MRA" if status == "cipm-mra"
        status.split(/[- ]/).map.with_index do |s, i|
          (%w(en de).include?(s) && i > 0) ? s : s.capitalize
        end.join(' ')
      end

      def docid(isoxml, _out)
        super
        label1 = @lang == "fr" ? "Annexe" : "Appendix"
        label2 = @lang == "fr" ? "Appendix" : "Annexe"
        dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
        dn and set(:appendixid, @i18n.l10n("#{label1} #{dn&.text}"))
        dn and set(:appendixid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metanorma-bipm-0.0.2 lib/isodoc/bipm/metadata.rb
metanorma-bipm-0.0.1 lib/isodoc/bipm/metadata.rb