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



51
52
53
54
55
56
# File 'lib/metanorma/requirements/modspec.rb', line 51

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.join("<br/>")
end

#recommend_title(node, out) ⇒ Object



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

def recommend_title(node, out)
  label = node.at(ns("./identifier")) or return
  out.add_child("<tr><td>#{@labels['modspec']['identifier']}</td>"\
                "<td><tt>#{label.children.to_xml}</tt></td>")
end

#recommendation_header(reqt, out) ⇒ Object

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



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

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
16
# 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 += l10n(": ") if lbl
  lbl += title.children.to_xml
  lbl
end

#requirement_component_parse(node, out) ⇒ Object



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

def requirement_component_parse(node, out)
  if node["exclude"] != "true" && node.name == "description"
    lbl = "statement"
    lbl = "declaration" if recommend_class(node) == "recommendclass"
    out << "<tr><td>#{@labels['modspec'][lbl]}</td>"\
           "<td>#{node.children.to_xml}</td></tr>"
  else
    super
  end
end

#requirement_table_cleanup(table) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/metanorma/requirements/modspec.rb', line 41

def requirement_table_cleanup(table)
  return table unless table["type"] == "recommendclass"

  ins = table.at(ns("./tbody/tr[td/table]")) or return table
  ins.replace("<tr><td>#{@labels['modspec']['provisions']}</td>" +
              "<td>#{nested_tables_names(table)}</td></tr>")
  table.xpath(ns("./tbody/tr[td/table]")).each(&:remove)
  table
end