Sha256: 8eb3f453a885ff0d44fcce4a06768f6b6e0c7ec54b70cfd357951c490fc57e17

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

module IsoDoc
  module Iec
    class Xref < IsoDoc::Iso::Xref
      def parse(docxml)
        id = docxml&.at(ns("//bibdata/docnumber"))&.text
        @is_iev = id == "60050"
        id = docxml&.at(ns("//bibdata/docidentifier[@type = 'ISO']"))&.text
        m = /60050-(\d+)/.match(id) and @iev_part = m[1]
        super
      end

      def introduction_names(clause)
        return super unless @is_iev
      end

      def initial_anchor_names(d)
        super
        return unless @is_iev
        terms_iev_names(d)
        middle_section_asset_names(d)
        termnote_anchor_names(d)
        termexample_anchor_names(d)
      end

      def terms_iev_names(d)
        d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
          num = "#{@iev_part}-%02d" % [i+1]
          @anchors[t["id"]] =
            { label: num, xref: l10n("#{@labels["section_iev"]}-#{num}"), level: 2,
              type: "clause" }
          t.xpath(ns("./term")).each_with_index do |c, i|
            num2 = "%02d" % [i+1]
            section_names1(c, "#{num}-#{num2}", 3)
          end
        end
      end

      def annex_name_lbl(clause, num)
        obl = l10n("(#{@labels["inform_annex"]})")
        obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
        l10n("<b>#{@labels["annex"]} #{num}</b><br/><br/>#{obl}")
      end
    end
  end
end

Version data entries

8 entries across 6 versions & 2 rubygems

Version Path
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/metanorma-iec-1.1.2/lib/isodoc/iec/xref.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/metanorma-iec-1.1.3/lib/isodoc/iec/xref.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/metanorma-iec-1.1.2/lib/isodoc/iec/xref.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/metanorma-iec-1.1.3/lib/isodoc/iec/xref.rb
metanorma-iec-1.1.3 lib/isodoc/iec/xref.rb
metanorma-iec-1.1.2 lib/isodoc/iec/xref.rb
metanorma-iec-1.1.1 lib/isodoc/iec/xref.rb
metanorma-iec-1.1.0 lib/isodoc/iec/xref.rb