class IsoDoc::Unece::Metadata
Constants
- MONTHS
Public Class Methods
new(lang, script, labels)
click to toggle source
Calls superclass method
# File lib/isodoc/unece/metadata.rb, line 9 def initialize(lang, script, labels) super here = File.dirname(__FILE__) set(:logo, File.expand_path(File.join(here, "html", "logo.jpg"))) end
Public Instance Methods
docid(isoxml, _out)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 65 def docid(isoxml, _out) dn = isoxml.at(ns("//bibdata/docidentifier"))&.text set(:docnumber, dn) type = isoxml&.at(ns("//bibdata/ext/doctype"))&.text set(:formatted_docnumber, type == "recommendation" ? "UN/CEFACT Recommendation #{dn}" : dn) end
extract_languages(nodeset)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 25 def extract_languages(nodeset) lgs = [] nodeset.each do |l| l && ISO_639&.find(l.text)&.english_name && lgs << ISO_639.find(l.text).english_name end lgs.map { |l| l == "Spanish; Castilian" ? "Spanish" : l } end
monthyr(isodate)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 107 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
multival(isoxml, xpath)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 47 def multival(isoxml, xpath) items = [] isoxml.xpath(ns(xpath)).each { |i| items << i.text } items end
session(isoxml, _out)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 53 def session(isoxml, _out) set(:session_number, isoxml&.at(ns("//bibdata/ext/session/number"))&.text&.to_i&. localize&.to_rbnf_s("SpelloutRules", "spellout-ordinal")&.capitalize) set(:session_date, isoxml&.at(ns("//bibdata/ext/session/date"))&.text) set(:session_collaborator, isoxml&.at(ns("//bibdata/ext/session/collaborator"))&.text) set(:session_id, isoxml&.at(ns("//bibdata/ext/session/id"))&.text) set(:item_footnote, isoxml&.at(ns("//bibdata/ext/session/item-footnote"))&.text) set(:session_itemnumber, multival(isoxml, "//bibdata/ext/session/item-number")) set(:session_itemname, multival(isoxml, "//bibdata/ext/session/item-name")) set(:session_subitemname, multival(isoxml, "//bibdata/ext/session/subitem-name")) end
status_abbr(status)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 72 def status_abbr(status) case status when "working-draft" then "wd" when "committee-draft" then "cd" when "draft-standard" then "d" else "" end end
subtitle(isoxml, _out)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 20 def subtitle(isoxml, _out) main = isoxml&.at(ns("//bibdata/title[@language='en' and @type='subtitle']"))&.text set(:docsubtitle, main) end
title(isoxml, _out)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 15 def title(isoxml, _out) main = isoxml&.at(ns("//bibdata/title[@language='en' and @type='main']"))&.text set(:doctitle, main) end
unpublished(status)
click to toggle source
# File lib/isodoc/unece/metadata.rb, line 82 def unpublished(status) !%w(published withdrawn).include? status.downcase end
version(isoxml, _out)
click to toggle source
Calls superclass method
# File lib/isodoc/unece/metadata.rb, line 86 def version(isoxml, _out) super revdate = get[:revdate] set(:revdate_monthyear, monthyr(revdate)) end