Class: IsoDoc::Ogc::Xref
- Inherits:
-
Xref
- Object
- Xref
- IsoDoc::Ogc::Xref
- Defined in:
- lib/isodoc/ogc/xref.rb
Instance Method Summary collapse
- #initial_anchor_names(doc) ⇒ Object
- #middle_section_asset_names(doc) ⇒ Object
- #preface_anchor_names(doc) ⇒ Object
- #preface_names_numbered(clause) ⇒ Object
- #preface_names_numbered1(clause, num, level) ⇒ Object
- #preface_number(num, level) ⇒ Object
- #reference_names(ref) ⇒ Object
Instance Method Details
#initial_anchor_names(doc) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/isodoc/ogc/xref.rb', line 7 def initial_anchor_names(doc) if @parse_settings.empty? || @parse_settings[:clauses] preface_anchor_names(doc) n = Counter.new n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1) n = section_names(doc.at(ns("//clause[@type = 'conformance']")), n, 1) n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1) n = section_names( doc.at(ns("//sections/terms | //sections/clause[descendant::terms]")), n, 1 ) n = section_names(doc.at(ns("//sections/definitions")), n, 1) clause_names(doc, n) end end |
#middle_section_asset_names(doc) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/isodoc/ogc/xref.rb', line 43 def middle_section_asset_names(doc) middle_sections = "//clause[@type = 'scope' or @type = 'conformance'] | //foreword | "\ "//introduction | //preface/abstract | //submitters | "\ "//acknowledgements | //preface/clause | "\ " #{@klass.norm_ref_xpath} | //sections/terms | "\ "//sections/definitions | //clause[parent::sections]" sequential_asset_names(doc.xpath(ns(middle_sections))) end |
#preface_anchor_names(doc) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/isodoc/ogc/xref.rb', line 23 def preface_anchor_names(doc) @prefacenum = 0 ["//preface/abstract", "//preface/clause[@type = 'executivesummary']", "//preface/clause[@type = 'keywords']", "//foreword", "//preface/clause[@type = 'security']", "//preface/clause[@type = 'submitting_orgs']", "//submitters", "//introduction"].each do |path| preface_names_numbered(doc.at(ns(path))) end doc.xpath(ns("//preface/clause[not(@type = 'keywords' or "\ "@type = 'submitting_orgs' or @type = 'security' or "\ "@type = 'executivesummary')]")) .each { |c| preface_names_numbered(c) } preface_names_numbered(doc.at(ns("//acknowledgements"))) sequential_asset_names( doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\ "//submitters | //acknowledgements | //preface/clause")), ) end |
#preface_names_numbered(clause) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/isodoc/ogc/xref.rb', line 53 def preface_names_numbered(clause) return if clause.nil? @prefacenum += 1 pref = preface_number(@prefacenum, 1) @anchors[clause["id"]] = { label: pref, level: 1, xref: preface_clause_name(clause), type: "clause" } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| preface_names_numbered1(c, "#{pref}.#{preface_number(i + 1, 2)}", 2) end end |
#preface_names_numbered1(clause, num, level) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/isodoc/ogc/xref.rb', line 66 def preface_names_numbered1(clause, num, level) @anchors[clause["id"]] = { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"), type: "clause", elem: @labels["clause"] } clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i| lbl = "#{num}.#{preface_number(i + 1, level + 1)}" preface_names_numbered1(c, lbl, level + 1) end end |
#preface_number(num, level) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/isodoc/ogc/xref.rb', line 76 def preface_number(num, level) case level when 1 then RomanNumerals.to_roman(num).upcase when 2 then (64 + num).chr.to_s when 3 then num.to_s when 4 then (96 + num).chr.to_s when 5 then RomanNumerals.to_roman(num).downcase when 6 then "(#{num})" when 7 then "(#{(96 + num).chr})" when 8 then "(#{RomanNumerals.to_roman(num).downcase})" else num.to_s end end |
#reference_names(ref) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/isodoc/ogc/xref.rb', line 90 def reference_names(ref) super return unless @klass.ogc_draft_ref?(ref) @anchors[ref["id"]] = { xref: "#{@anchors[ref['id']][:xref]} (draft)" } end |