lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb in adiwg-mdtranslator-2.0.0rc11 vs lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb in adiwg-mdtranslator-2.0.0rc13

- old
+ new

@@ -1,10 +1,11 @@ # sbJson 1.0 writer citation # History: # Stan Smith 2017-05-16 original script +require 'adiwg/mdtranslator/internal/module_dateTimeFun' require_relative 'sbJson_codelists' module ADIWG module Mdtranslator module Writers @@ -18,11 +19,10 @@ # title, {citation.title} # uri, [] {citation.onlineResource[]} def self.build(hCitation) citation = '' - role = '' # names aIndexes = [] hCitation[:responsibleParties].each do |hResponsibility| role = hResponsibility[:roleName] @@ -42,21 +42,21 @@ aIndexes.uniq! aIndexes.each do |hIndex| hContact = ADIWG::Mdtranslator::Writers::SbJson.get_contact_by_index(hIndex[:index]) unless hContact.empty? unless hContact[:name].nil? - citation += hContact[:name] + '(' + hIndex[:role] + '), ' + sbRole = Codelists.codelist_iso_to_sb('iso_sb_role', :isoCode => hIndex[:role]) + sbRole = sbRole.nil? ? hIndex[:role] : sbRole + citation += hContact[:name] + '(' + sbRole + '), ' end end end # dates hCitation[:dates].each do |hDate| - dateStr = AdiwgDateTimeFun.stringFromDateObject(hDate) + dateStr = AdiwgDateTimeFun.stringDateFromDateObject(hDate) dateType = Codelists.codelist_iso_to_sb('iso_sb_date', :isoCode => hDate[:dateType]) - if dateType.nil? - citation += dateStr + ', ' - else + unless dateType.nil? citation += dateStr + '(' + dateType + '), ' end end # title