Class: IsoDoc::Mpfd::Metadata

Inherits:
IsoDoc::Metadata
  • Object
show all
Defined in:
lib/isodoc/mpfd/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(lang, script, labels) ⇒ Metadata

Returns a new instance of Metadata.



9
10
11
12
# File 'lib/isodoc/mpfd/metadata.rb', line 9

def initialize(lang, script, labels)
  super
  # set(:status, "")
end

Instance Method Details

#author(isoxml, _out) ⇒ Object



23
24
25
26
# File 'lib/isodoc/mpfd/metadata.rb', line 23

def author(isoxml, _out)
  publisher = isoxml.at(ns("//bibdata/contributor/organization/name"))
  set(:publisher, publisher.text) if publisher
end

#docid(isoxml, _out) ⇒ Object



28
29
30
31
# File 'lib/isodoc/mpfd/metadata.rb', line 28

def docid(isoxml, _out)
  docnumber = isoxml.at(ns("//bibdata/docidentifier"))
  set(:docnumber, docnumber&.text)
end

#doctype(isoxml, _out) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/isodoc/mpfd/metadata.rb', line 33

def doctype(isoxml, _out)
  b = isoxml.at(ns("//bibdata")) || return
  return unless b["type"]
  t = b["type"].split(/[- ]/).
    map{ |w| w.capitalize unless w == "MPF" }.join(" ")
  set(:doctype, t)
end

#monthyr(isodate) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/isodoc/mpfd/metadata.rb', line 66

def monthyr(isodate)
  date = DateTime.parse(isodate)
  date.strftime('%-d %B %Y')    #=> "Sun 04 Feb 2001"
rescue
  # invalid dates get thrown
  isodate
end

#status_abbr(status) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/isodoc/mpfd/metadata.rb', line 41

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) ⇒ Object



19
20
21
# File 'lib/isodoc/mpfd/metadata.rb', line 19

def subtitle(_isoxml, _out)
  nil
end

#title(isoxml, _out) ⇒ Object



14
15
16
17
# File 'lib/isodoc/mpfd/metadata.rb', line 14

def title(isoxml, _out)
  main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text
  set(:doctitle, main)
end

#version(isoxml, _out) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/isodoc/mpfd/metadata.rb', line 51

def version(isoxml, _out)
  super
  revdate = get[:revdate]
  set(:revdate_monthyear, monthyr(revdate))
  edition = isoxml.at(ns("//version/edition"))
  if edition
    set(
      :edition,
      edition.text.to_i.localize.
        to_rbnf_s("SpelloutRules", "spellout-ordinal").
        split(/(\W)/).map(&:capitalize).join
    )
  end
end