Sha256: e0be627af4d6cc6dd9dc291bed6be1417bb32362fc4457aefe31f29d3d02d967

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

module Relaton
  class Bibdata
    attr_accessor *%i[
      docid
      doctype
      title
      stage
      relation
      uri
      revdate
      abstract
      technical_committee
    ]

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

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

    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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-cli-0.1.0 lib/relaton/bibdata.rb