Class: IsoDoc::Ogc::Metadata
- Inherits:
-
Metadata
- Object
- Metadata
- IsoDoc::Ogc::Metadata
- Defined in:
- lib/isodoc/ogc/metadata.rb
Instance Method Summary collapse
- #author(isoxml, _out) ⇒ Object
- #bibdate(isoxml, _out) ⇒ Object
- #docdate(isoxml) ⇒ Object
- #docid(isoxml, _out) ⇒ Object
- #docsubtype_abbr(subtype, _type) ⇒ Object
- #doctype(isoxml, _out) ⇒ Object
- #doctype_abbr(type) ⇒ Object
-
#initialize(lang, script, i18n) ⇒ Metadata
constructor
A new instance of Metadata.
- #status_print(status) ⇒ Object
- #subtitle(_isoxml, _out) ⇒ Object
- #title(isoxml, _out) ⇒ Object
- #type_capitalise(type) ⇒ Object
- #unpublished(status) ⇒ Object
- #url(xml, _out) ⇒ Object
- #version(isoxml, _out) ⇒ Object
Constructor Details
#initialize(lang, script, i18n) ⇒ Metadata
Returns a new instance of Metadata.
38 39 40 41 42 43 44 45 46 |
# File 'lib/isodoc/ogc/metadata.rb', line 38 def initialize(lang, script, i18n) super here = File.dirname(__FILE__) set(:logo_old, File.(File.join(here, "html", "logo.png"))) set(:logo_new, File.(File.join(here, "html", "logo.2021.svg"))) end |
Instance Method Details
#author(isoxml, _out) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/isodoc/ogc/metadata.rb', line 57 def (isoxml, _out) tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee")) set(:tc, tc.text) if tc = isoxml.xpath(ns("//bibdata/contributor"\ "[role/@type = 'author']/person")) set(:authors, extract_person_names()) editors = isoxml.xpath(ns("//bibdata/contributor"\ "[role/@type = 'editor']/person")) set(:editors, extract_person_names(editors)) contributors = isoxml.xpath(ns("//bibdata/contributor"\ "[role/@type = 'contributor']/person")) set(:contributors, extract_person_names(contributors)) agency(isoxml) end |
#bibdate(isoxml, _out) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/isodoc/ogc/metadata.rb', line 134 def bibdate(isoxml, _out) super d = docdate(isoxml) begin old = d.nil? || d.empty? || DateTime.iso8601("2021-11-08") > DateTime.parse(d.text) rescue StandardError old = false end set(:logo_word, old ? get[:logo_old] : get[:logo_new]) end |
#docdate(isoxml) ⇒ Object
125 126 127 128 129 130 131 132 |
# File 'lib/isodoc/ogc/metadata.rb', line 125 def docdate(isoxml) isoxml.xpath(ns("//bibdata/date[@type = 'published']/on")) || isoxml.xpath(ns("//bibdata/date[@type = 'published']/from")) || isoxml.xpath(ns("//bibdata/date[@type = 'issued']/on")) || isoxml.xpath(ns("//bibdata/date[@type = 'issued']/from")) || isoxml.xpath(ns("//bibdata/date/from")) || isoxml.xpath(ns("//bibdata/date/on")) end |
#docid(isoxml, _out) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/isodoc/ogc/metadata.rb', line 72 def docid(isoxml, _out) set(:docnumber, isoxml&.at(ns("//bibdata/docidentifier"\ "[@type = 'ogc-internal']"))&.text) set(:externalid, isoxml&.at(ns("//bibdata/docidentifier"\ "[@type = 'ogc-external']"))&.text) end |
#docsubtype_abbr(subtype, _type) ⇒ Object
117 118 119 |
# File 'lib/isodoc/ogc/metadata.rb', line 117 def docsubtype_abbr(subtype, _type) IsoDoc::Ogc::DOCSUBTYPE_ABBR[subtype] || st end |
#doctype(isoxml, _out) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/isodoc/ogc/metadata.rb', line 102 def doctype(isoxml, _out) if t = isoxml&.at(ns("//bibdata/ext/doctype"))&.text set(:doctype, type_capitalise(t)) set(:doctype_abbr, doctype_abbr(t)) if st = isoxml&.at(ns("//bibdata/ext/subdoctype"))&.text set(:docsubtype, type_capitalise(st)) set(:docsubtype_abbr, docsubtype_abbr(st, t)) end end end |
#doctype_abbr(type) ⇒ Object
113 114 115 |
# File 'lib/isodoc/ogc/metadata.rb', line 113 def doctype_abbr(type) IsoDoc::Ogc::DOCTYPE_ABBR[type] || type end |
#status_print(status) ⇒ Object
121 122 123 |
# File 'lib/isodoc/ogc/metadata.rb', line 121 def status_print(status) type_capitalise(status) end |
#subtitle(_isoxml, _out) ⇒ Object
53 54 55 |
# File 'lib/isodoc/ogc/metadata.rb', line 53 def subtitle(_isoxml, _out) nil end |
#title(isoxml, _out) ⇒ Object
48 49 50 51 |
# File 'lib/isodoc/ogc/metadata.rb', line 48 def title(isoxml, _out) main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text set(:doctitle, main) end |
#type_capitalise(type) ⇒ Object
96 97 98 99 100 |
# File 'lib/isodoc/ogc/metadata.rb', line 96 def type_capitalise(type) type.split(/[- ]/).map do |w| %w(SWG).include?(w) ? w : w.capitalize end.join(" ") end |
#unpublished(status) ⇒ Object
79 80 81 |
# File 'lib/isodoc/ogc/metadata.rb', line 79 def unpublished(status) !%w(approved deprecated retired).include?(status.downcase) end |
#url(xml, _out) ⇒ Object
90 91 92 93 94 |
# File 'lib/isodoc/ogc/metadata.rb', line 90 def url(xml, _out) super a = xml.at(ns("//bibdata/uri[@type = 'previous']")) and set(:previousuri, a.text) end |
#version(isoxml, _out) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/isodoc/ogc/metadata.rb', line 83 def version(isoxml, _out) super set(:edition, isoxml&.at(ns("//bibdata/edition"))&.text) lg = ISO_639.find_by_code(isoxml&.at(ns("//bibdata/language"))&.text) set(:doclanguage, lg ? lg[3] : "English") end |