Class: Relaton::Bibdata

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/bibdata.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Bibdata

Returns a new instance of Bibdata.



15
16
17
18
19
# File 'lib/relaton/bibdata.rb', line 15

def initialize(options)
  options.each_pair do |k,v|
    send("#{k.to_s}=", v)
  end
end

Instance Method Details

#docid_codeObject



21
22
23
# File 'lib/relaton/bibdata.rb', line 21

def docid_code
  docid.downcase.gsub(/[\s\/]/, "-") || ""
end

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/relaton/bibdata.rb', line 25

def to_xml
  datetype = stage.casecmp("published") == 0 ? "published" : "updated"

  ret = "<bibdata type='#{doctype}'>\n"
  ret += "<title>#{title}</title>\n"
  ret += "<uri>#{uri}</uri>\n"
  ret += "<docidentifier>#{docid}</docidentifier>\n"
  ret += "<date type='#{datetype}'><on>#{revdate}</on></date>\n" if revdate
  ret += "<abstract>#{abstract}</abstract>\n" if abstract
  ret += "<status>#{stage}</status>\n" if stage
  ret += "<technical-committee>#{technical_committee}</technical-committee>\n" if technical_committee
  ret += "</bibdata>\n"
end