Class: Metanorma::Requirements::Modspec::Iso

Inherits:
Metanorma::Requirements::Modspec show all
Defined in:
lib/metanorma/requirements/modspec.rb

Overview

Don’t want to inherit from Metanorma::Requirements::Modspec

Instance Method Summary collapse

Instance Method Details

#nested_tables_names(table) ⇒ Object



40
41
42
43
44
45
# File 'lib/metanorma/requirements/modspec.rb', line 40

def nested_tables_names(table)
  table.xpath(ns("./tbody/tr/td/table"))
    .each_with_object([]) do |t, m|
      m << t.at(ns("./name")).children.to_xml
    end
end

#postprocess_anchor_struct(block, anchor) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/metanorma/requirements/modspec.rb', line 47

def postprocess_anchor_struct(block, anchor)
  super
  anchor[:modspec] = anchor[:xref_bare]
  if l = block.at(ns("./title"))
    anchor[:modspec] =
      l10n("#{anchor[:modspec]}: #{l.children.to_xml.strip}")
  end
  anchor
end

#recommendation_header(reqt, out) ⇒ Object

ISO labels modspec reqt as table, with reqt label as title



18
19
20
21
# File 'lib/metanorma/requirements/modspec.rb', line 18

def recommendation_header(reqt, out)
  n = reqt.at(ns("./name")) and out << n
  out
end

#recommendation_label(elem, type, xrefs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/metanorma/requirements/modspec.rb', line 6

def recommendation_label(elem, type, xrefs)
  lbl = super
  title = elem.at(ns("./title"))
  return lbl unless title &&
    elem.ancestors("requirement, recommendation, permission").empty?

  lbl += ": " if lbl
  lbl += title.children.to_xml
  l10n(lbl)
end

#requirement_table_cleanup_nested_replacement(node, table) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/metanorma/requirements/modspec.rb', line 31

def requirement_table_cleanup_nested_replacement(node, table)
  label = "provision"
  node["type"] == "conformanceclass" and label = "conformancetest"
  n = nested_tables_names(table)
  hdr = @i18n.inflect(@labels["modspec"][label],
                      number: n.size == 1 ? "sg" : "pl")
  "<tr><th>#{hdr}</th><td>#{n.join('<br/>')}</td></tr>"
end

#requirement_table_nested_cleanup(node, table) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/metanorma/requirements/modspec.rb', line 23

def requirement_table_nested_cleanup(node, table)
  table["type"] == "recommendclass" or return table
  ins = table.at(ns("./tbody/tr[td/table]")) or return table
  ins.replace(requirement_table_cleanup_nested_replacement(node, table))
  table.xpath(ns("./tbody/tr[td/table]")).each(&:remove)
  table
end