Class: IsoDoc::IEEE::Metadata
- Inherits:
-
Metadata
- Object
- Metadata
- IsoDoc::IEEE::Metadata
- Defined in:
- lib/isodoc/ieee/metadata.rb
Instance Method Summary collapse
- #author(xml, _out) ⇒ Object
- #bg(xml) ⇒ Object
- #bibdate(isoxml, _out) ⇒ Object
- #ddMMMyyyy(isodate) ⇒ Object
- #docid(isoxml, _out) ⇒ Object
- #doctype(isoxml, _out) ⇒ Object
- #fulltitle(type, draft) ⇒ Object
-
#initialize(lang, script, i18n, fonts_options = {}) ⇒ Metadata
constructor
A new instance of Metadata.
- #otherid(isoxml, _out) ⇒ Object
- #society(xml) ⇒ Object
- #tc(xml) ⇒ Object
- #title(isoxml, _out) ⇒ Object
- #wg(xml) ⇒ Object
Constructor Details
#initialize(lang, script, i18n, fonts_options = {}) ⇒ Metadata
Returns a new instance of Metadata.
7 8 9 10 |
# File 'lib/isodoc/ieee/metadata.rb', line 7 def initialize(lang, script, i18n, = {}) super @metadata[:issueddate] = "<Date Approved>" end |
Instance Method Details
#author(xml, _out) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/isodoc/ieee/metadata.rb', line 36 def (xml, _out) super society(xml) tc(xml) wg(xml) bg(xml) end |
#bg(xml) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/isodoc/ieee/metadata.rb', line 62 def bg(xml) bg = xml.at(ns("//bibdata/ext/editorialgroup/"\ "balloting-group")) or return nil set(:balloting_group, bg.text) set(:balloting_group_type, bg["type"]) end |
#bibdate(isoxml, _out) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/isodoc/ieee/metadata.rb', line 12 def bibdate(isoxml, _out) isoxml.xpath(ns("//bibdata/date[@format = 'ddMMMyyyy']")).each do |d| set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d)) end draft = isoxml.at(ns("//bibdata/date[@type = 'issued']")) || isoxml.at(ns("//bibdata/date[@type = 'circulated']")) || isoxml.at(ns("//bibdata/date[@type = 'created']")) || isoxml.at(ns("//bibdata/version/revision-date")) or return date = DateTime.parse(draft.text) set(:draft_month, date.strftime("%B")) set(:draft_year, date.strftime("%Y")) rescue StandardError end |
#ddMMMyyyy(isodate) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/isodoc/ieee/metadata.rb', line 106 def ddMMMyyyy(isodate) return nil if isodate.nil? arr = isodate.split("-") if arr.size == 1 && (/^\d+$/.match isodate) Date.new(*arr.map(&:to_i)).strftime("%Y") elsif arr.size == 2 Date.new(*arr.map(&:to_i)).strftime("%b %Y") else Date.parse(isodate).strftime("%d %b %Y") end end |
#docid(isoxml, _out) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/isodoc/ieee/metadata.rb', line 77 def docid(isoxml, _out) super id = "bibdata/docidentifier[@type = 'IEEE']" dn = isoxml.at(ns("//#{id}[@scope = 'PDF']")) set(:stdid_pdf, dn&.text || "STDXXXXX") dn = isoxml.at(ns("//#{id}[@scope = 'print']")) set(:stdid_print, dn&.text || "STDPDXXXXX") dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and set(:amd, dn.text) dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and set(:corr, dn.text) end |
#doctype(isoxml, _out) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/isodoc/ieee/metadata.rb', line 26 def doctype(isoxml, _out) b = isoxml.at(ns("//bibdata/ext/doctype"))&.text or return set(:doctype, b.split(/[- ]/).map(&:capitalize).join(" ")) set(:doctype_abbrev, @labels["doctype_abbrev"][b]) s = isoxml.at(ns("//bibdata/ext/subdoctype"))&.text and set(:docsubtype, s.split(/[- ]/).map(&:capitalize).join(" ")) s = isoxml.at(ns("//bibdata/ext/trial-use"))&.text and s == "true" and set(:trial_use, true) end |
#fulltitle(type, draft) ⇒ Object
100 101 102 103 104 |
# File 'lib/isodoc/ieee/metadata.rb', line 100 def fulltitle(type, draft) title = "#{type || '???'} for #{@metadata[:doctitle] || '???'}" draft and title = "Draft #{title}" title end |
#otherid(isoxml, _out) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/isodoc/ieee/metadata.rb', line 69 def otherid(isoxml, _out) id = "bibdata/docidentifier[@type = 'ISBN']" dn = isoxml.at(ns("//#{id}[@scope = 'PDF']")) set(:isbn_pdf, dn&.text || "978-0-XXXX-XXXX-X") dn = isoxml.at(ns("//#{id}[@scope = 'print']")) set(:isbn_print, dn&.text || "978-0-XXXX-XXXX-X") end |
#society(xml) ⇒ Object
44 45 46 47 48 |
# File 'lib/isodoc/ieee/metadata.rb', line 44 def society(xml) society = xml.at(ns("//bibdata/ext/editorialgroup/"\ "society"))&.text || "<Society>" set(:society, society) end |
#tc(xml) ⇒ Object
50 51 52 53 54 |
# File 'lib/isodoc/ieee/metadata.rb', line 50 def tc(xml) tc = xml.at(ns("//bibdata/ext/editorialgroup/"\ "committee"))&.text || "<Committee Name>" set(:technical_committee, tc) end |
#title(isoxml, _out) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/isodoc/ieee/metadata.rb', line 90 def title(isoxml, _out) super draft = isoxml&.at(ns("//bibdata/version/draft")) doctype(isoxml, _out) set(:full_doctitle, fulltitle(@metadata[:doctype], draft)) set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft)) prov = isoxml&.at(ns("//bibdata/title[@type='provenance']")) and set(:provenance_doctitle, prov.children.to_xml) end |
#wg(xml) ⇒ Object
56 57 58 59 60 |
# File 'lib/isodoc/ieee/metadata.rb', line 56 def wg(xml) wg = xml.at(ns("//bibdata/ext/editorialgroup/"\ "working-group")) or return nil set(:working_group, wg.text) end |