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
- #extract_person_names(authors) ⇒ 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/name")) set(:authors, extract_person_names()) editors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'editor']/person/name")) set(:editors, extract_person_names(editors)) end |
#docid(isoxml, _out) ⇒ Object
47 48 49 50 |
# File 'lib/isodoc/ogc/metadata.rb', line 47 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 |
#extract_person_names(authors) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/isodoc/ogc/metadata.rb', line 31 def extract_person_names() ret = [] .each do |a| if a.at(ns("./completename")) ret << a.at(ns("./completename")).text else fn = [] forenames = a.xpath(ns("./forename")) forenames.each { |f| fn << f.text } surname = a&.at(ns("./surname"))&.text ret << fn.join(" ") + " " + surname end end ret end |
#keywords(isoxml, _out) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/isodoc/ogc/metadata.rb', line 59 def keywords(isoxml, _out) keywords = [] isoxml.xpath(ns("//bibdata/keyword")).each do |kw| keywords << kw.text end set(:keywords, keywords) end |
#monthyr(isodate) ⇒ Object
90 91 92 93 94 |
# File 'lib/isodoc/ogc/metadata.rb', line 90 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
56 57 |
# File 'lib/isodoc/ogc/metadata.rb', line 56 def status_abbr(status) end |
#status_print(status) ⇒ Object
52 53 54 |
# File 'lib/isodoc/ogc/metadata.rb', line 52 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
96 97 98 99 |
# File 'lib/isodoc/ogc/metadata.rb', line 96 def url(xml, _out) super a = xml.at(ns("//bibdata/source[@type = 'previous']")) and set(:previousuri, a.text) end |
#version(isoxml, _out) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/isodoc/ogc/metadata.rb', line 67 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 |