lib/adiwg/mdtranslator/writers/html/sections/html_associatedResource.rb in adiwg-mdtranslator-1.4.0 vs lib/adiwg/mdtranslator/writers/html/sections/html_associatedResource.rb in adiwg-mdtranslator-2.0.0rc2

- old
+ new

@@ -1,73 +1,73 @@ # HTML writer # associated resource # History: +# Stan Smith 2017-04-04 refactored for mdTranslator 2.0 # Stan Smith 2015-08-21 original script +require_relative 'html_resourceType' require_relative 'html_citation' module ADIWG - module Mdtranslator - module Writers - module Html + module Mdtranslator + module Writers + module Html - class MdHtmlAssociatedResource - def initialize(html) - @html = html - end + class Html_AssociatedResource - def writeHtml(hAssRes) + def initialize(html) + @html = html + end - # classes used - htmlCitation = MdHtmlCitation.new(@html) + def writeHtml(hResource) - # associated resource - resource type - s = hAssRes[:resourceType] - if !s.nil? - @html.em('Resource type: ') - @html.text!(s) - @html.br - end + # classes used + typeClass = Html_ResourceType.new(@html) + citationClass = Html_Citation.new(@html) - # associated resource - association type - s = hAssRes[:associationType] - if !s.nil? - @html.em('Association type: ') - @html.text!(s) - @html.br - end + # associated resource - resource type + hResource[:resourceTypes].each do |hType| + typeClass.writeHtml(hType) + end - # associated resource - initiative type - s = hAssRes[:initiativeType] - if !s.nil? - @html.em('Initiative type: ') - @html.text!(s) - @html.br - end + # associated resource - association type {associationTypeCode} + unless hResource[:associationType].nil? + @html.em('Association type: ') + @html.text!(hResource[:associationType]) + @html.br + end - # associated resource - citation - hCitation = hAssRes[:resourceCitation] - if !hCitation.empty? - @html.em('Resource citation: ') - @html.section(:class=>'block') do - htmlCitation.writeHtml(hCitation) - end + # associated resource - initiative type {initiativeTypeCode} + unless hResource[:initiativeType].nil? + @html.em('Initiative type: ') + @html.text!(hResource[:initiativeType]) + @html.br + end + + # associated resource - resource citation {citation} + unless hResource[:resourceCitation].empty? + @html.details do + @html.summary('Resource citation', {'class' => 'h5'}) + @html.section(:class => 'block') do + citationClass.writeHtml(hResource[:resourceCitation]) end + end + end - # associated resource - metadata citation - hCitation = hAssRes[:metadataCitation] - if !hCitation.empty? - @html.em('Metadata citation: ') - @html.section(:class=>'block') do - htmlCitation.writeHtml(hCitation) - end + # associated resource - metadata citation + unless hResource[:metadataCitation].empty? + @html.details do + @html.summary('Metadata citation', {'class' => 'h5'}) + @html.section(:class => 'block') do + citationClass.writeHtml(hResource[:metadataCitation]) end + end + end - end # writeHtml + end # writeHtml + end # Html_AssociatedResource - end # class - - end - end - end + end + end + end end