lib/adiwg/mdtranslator/writers/iso/classes/class_keyword.rb in adiwg-mdtranslator-0.10.2 vs lib/adiwg/mdtranslator/writers/iso/classes/class_keyword.rb in adiwg-mdtranslator-0.12.0

- old
+ new

@@ -3,61 +3,70 @@ # History: # Stan Smith 2013-09-18 original script # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure # Stan Smith 2014-08-21 removed keyword thesaurus link; use citation onlineResource +# Stan Smith 2014-12-12 refactored to handle namespacing readers and writers require 'code_keywordType' require 'class_citation' -class MD_Keywords +module ADIWG + module Mdtranslator + module Writers + module Iso - def initialize(xml) - @xml = xml - end + class MD_Keywords - def writeXML(hDKeyword) + def initialize(xml) + @xml = xml + end - # classes used - citationClass = CI_Citation.new(@xml) - keywordCode = MD_KeywordTypeCode.new(@xml) + def writeXML(hDKeyword) - @xml.tag!('gmd:MD_Keywords') do + # classes used + citationClass = $WriterNS::CI_Citation.new(@xml) + keywordCode = $WriterNS::MD_KeywordTypeCode.new(@xml) - # keywords - keyword - required - aKeywords = hDKeyword[:keyword] - if aKeywords.empty? - @xml.tag!('gmd:keyword', {'gco:nilReason' => 'missing'}) - else - aKeywords.each do |keyword| - @xml.tag!('gmd:keyword') do - @xml.tag!('gco:CharacterString', keyword) - end - end - end + @xml.tag!('gmd:MD_Keywords') do - # keywords - type - MD_KeywordTypeCode - s = hDKeyword[:keywordType] - if !s.nil? - @xml.tag!('gmd:type') do - keywordCode.writeXML(s) - end - elsif $showAllTags - @xml.tag!('gmd:type') - end + # keywords - keyword - required + aKeywords = hDKeyword[:keyword] + if aKeywords.empty? + @xml.tag!('gmd:keyword', {'gco:nilReason' => 'missing'}) + else + aKeywords.each do |keyword| + @xml.tag!('gmd:keyword') do + @xml.tag!('gco:CharacterString', keyword) + end + end + end - hKeyCitation = hDKeyword[:keyTheCitation] - if !hKeyCitation.empty? - @xml.tag!('gmd:thesaurusName') do - citationClass.writeXML(hKeyCitation) - end - elsif $showAllTags - @xml.tag!('gmd:thesaurusName') - end + # keywords - type - MD_KeywordTypeCode + s = hDKeyword[:keywordType] + if !s.nil? + @xml.tag!('gmd:type') do + keywordCode.writeXML(s) + end + elsif $showAllTags + @xml.tag!('gmd:type') + end - end + hKeyCitation = hDKeyword[:keyTheCitation] + if !hKeyCitation.empty? + @xml.tag!('gmd:thesaurusName') do + citationClass.writeXML(hKeyCitation) + end + elsif $showAllTags + @xml.tag!('gmd:thesaurusName') + end - end + end -end + end + end + end + end + end +end