Class: IsoDoc::Ogc::Metadata
- Inherits:
-
Metadata
- Object
- Metadata
- IsoDoc::Ogc::Metadata
- Defined in:
- lib/isodoc/ogc/metadata.rb
Constant Summary collapse
- MONTHS =
{ "01": "January", "02": "February", "03": "March", "04": "April", "05": "May", "06": "June", "07": "July", "08": "August", "09": "September", "10": "October", "11": "November", "12": "December", }.freeze
Instance Method Summary collapse
- #author(isoxml, _out) ⇒ Object
- #docid(isoxml, _out) ⇒ Object
-
#initialize(lang, script, labels) ⇒ Metadata
constructor
A new instance of Metadata.
- #keywords(isoxml, _out) ⇒ Object
- #monthyr(isodate) ⇒ Object
- #status_abbr(status) ⇒ Object
- #status_print(status) ⇒ Object
- #subtitle(_isoxml, _out) ⇒ Object
- #title(isoxml, _out) ⇒ Object
- #url(xml, _out) ⇒ Object
- #version(isoxml, _out) ⇒ Object
Constructor Details
#initialize(lang, script, labels) ⇒ Metadata
Returns a new instance of Metadata.
8 9 10 11 |
# File 'lib/isodoc/ogc/metadata.rb', line 8 def initialize(lang, script, labels) super set(:status, "XXX") end |
Instance Method Details
#author(isoxml, _out) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/isodoc/ogc/metadata.rb', line 22 def (isoxml, _out) tc = isoxml.at(ns("//bibdata/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)) end |
#docid(isoxml, _out) ⇒ Object
31 32 33 34 |
# File 'lib/isodoc/ogc/metadata.rb', line 31 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 |
#keywords(isoxml, _out) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/isodoc/ogc/metadata.rb', line 43 def keywords(isoxml, _out) keywords = [] isoxml.xpath(ns("//bibdata/keyword")).each do |kw| keywords << kw.text end set(:keywords, keywords) end |
#monthyr(isodate) ⇒ Object
74 75 76 77 78 |
# File 'lib/isodoc/ogc/metadata.rb', line 74 def monthyr(isodate) m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate return isodate unless m && m[:yr] && m[:mo] return "#{MONTHS[m[:mo].to_sym]} #{m[:yr]}" end |
#status_abbr(status) ⇒ Object
40 41 |
# File 'lib/isodoc/ogc/metadata.rb', line 40 def status_abbr(status) end |
#status_print(status) ⇒ Object
36 37 38 |
# File 'lib/isodoc/ogc/metadata.rb', line 36 def status_print(status) status.split(/-/).map{ |w| w.capitalize }.join(" ") end |
#subtitle(_isoxml, _out) ⇒ Object
18 19 20 |
# File 'lib/isodoc/ogc/metadata.rb', line 18 def subtitle(_isoxml, _out) nil end |
#title(isoxml, _out) ⇒ Object
13 14 15 16 |
# File 'lib/isodoc/ogc/metadata.rb', line 13 def title(isoxml, _out) main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text set(:doctitle, main) end |
#url(xml, _out) ⇒ Object
80 81 82 83 |
# File 'lib/isodoc/ogc/metadata.rb', line 80 def url(xml, _out) super a = xml.at(ns("//bibdata/uri[@type = 'previous']")) and set(:previousuri, a.text) end |
#version(isoxml, _out) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/isodoc/ogc/metadata.rb', line 51 def version(isoxml, _out) super revdate = get[:revdate] set(:revdate_monthyear, monthyr(revdate)) set(:edition, isoxml&.at(ns("//version/edition"))&.text) set(:language, ISO_639.find_by_code(isoxml&.at(ns("//bibdata/language"))&.text)) end |