Class: Metanorma::Iho::Cleanup
- Inherits:
-
Generic::Cleanup
- Object
- Generic::Cleanup
- Metanorma::Iho::Cleanup
- Extended by:
- Forwardable
- Defined in:
- lib/metanorma/iho/cleanup.rb
Constant Summary collapse
- ID_LABELS =
{ appendixid: "Appendix", annexid: "Annex", part: "Part", supplementid: "Supplement", }.freeze
Instance Method Summary collapse
- #bibdata_docidentifier_cleanup(isoxml) ⇒ Object
-
#bibdata_docidentifier_enhance(id, parts) ⇒ Object
not language-specific, just space-delimited.
- #bibdata_docidentifier_i18n(isoxml) ⇒ Object
- #bibdata_docidentifier_i18n_prep(isoxml) ⇒ Object
Instance Method Details
#bibdata_docidentifier_cleanup(isoxml) ⇒ Object
6 7 8 9 |
# File 'lib/metanorma/iho/cleanup.rb', line 6 def bibdata_docidentifier_cleanup(isoxml) bibdata_docidentifier_i18n(isoxml) super end |
#bibdata_docidentifier_enhance(id, parts) ⇒ Object
not language-specific, just space-delimited
39 40 41 42 43 44 45 |
# File 'lib/metanorma/iho/cleanup.rb', line 39 def bibdata_docidentifier_enhance(id, parts) ret = %w(part appendixid annexid supplementid) .each_with_object([]) do |w, m| p = parts[w] and m << "#{ID_LABELS[w.to_sym]} #{p}" end id.children = "#{id.text} #{ret.join(' ')}" end |
#bibdata_docidentifier_i18n(isoxml) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/metanorma/iho/cleanup.rb', line 11 def bibdata_docidentifier_i18n(isoxml) id, parts = bibdata_docidentifier_i18n_prep(isoxml) parts.empty? and return id_alt = id.dup id.next = id_alt id_alt["type"] = "IHO-parent-document" id_alt.delete("primary") bibdata_docidentifier_enhance(id, parts) end |
#bibdata_docidentifier_i18n_prep(isoxml) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/metanorma/iho/cleanup.rb', line 21 def bibdata_docidentifier_i18n_prep(isoxml) id = isoxml.at("//bibdata/docidentifier[@type = 'IHO']") parts = %w(appendixid annexid part supplementid) .each_with_object({}) do |w, m| dn = isoxml.at("//bibdata/ext/structuredidentifier/#{w}") and m[w] = dn.text end [id, parts] end |