class ADIWG::Mdtranslator::Writers::Html::Html_Allocation

Public Class Methods

new(html) click to toggle source
# File lib/adiwg/mdtranslator/writers/html/sections/html_allocation.rb, line 18
def initialize(html)
   @html = html
end

Public Instance Methods

writeHtml(hAllocation) click to toggle source
# File lib/adiwg/mdtranslator/writers/html/sections/html_allocation.rb, line 22
def writeHtml(hAllocation)

   # classes used
   responsibilityClass = Html_Responsibility.new(@html)
   onlineClass = Html_OnlineResource.new(@html)

   # allocation - id
   unless hAllocation[:id].nil?
      @html.em('Source Allocation ID: ')
      @html.text!(hAllocation[:id])
      @html.br
   end

   # allocation - amount
   unless hAllocation[:amount].nil?
      @html.em('Amount: ')
      @html.text!(hAllocation[:amount].to_s)
      @html.br
   end

   # allocation - currency
   unless hAllocation[:currency].nil?
      @html.em('Currency: ')
      @html.text!(hAllocation[:currency])
      @html.br
   end

   # allocation - sourceId
   unless hAllocation[:sourceId].nil?
      hContact = Html_Document.getContact(hAllocation[:sourceId])
      @html.em('Source Contact: ')
      if hContact.empty?
         @html.text!("Contact #{hAllocation[:sourceId]} not found!")
      else
         @html.a(hContact[:contactId], 'href' => '#CID_'+hContact[:contactId])
      end
      @html.br
   end

   # allocation - recipientId
   unless hAllocation[:recipientId].nil?
      hContact = Html_Document.getContact(hAllocation[:recipientId])
      @html.em('Recipient Contact: ')
      if hContact.empty?
         @html.text!("Contact #{hAllocation[:recipientId]} not found!")
      else
         @html.a(hContact[:contactId], 'href' => '#CID_'+hContact[:contactId])
      end
      @html.br
   end

   # allocation - matching {Boolean}
   unless hAllocation[:matching].nil?
      @html.em('Matching Funds Provided: ')
      @html.text!(hAllocation[:matching].to_s)
      @html.br
   end

   # allocation - responsible parties [] {responsibleParty}
   hAllocation[:responsibleParties].each do |hResponsibility|
      @html.details do
         @html.summary(hResponsibility[:roleName], 'class' => 'h5')
         @html.section(:class => 'block') do
            responsibilityClass.writeHtml(hResponsibility)
         end
      end
   end

   # allocation - online resource [] {onlineResource}
   hAllocation[:onlineResources].each do |hOnline|
      @html.details do
         @html.summary('Online Resource', {'class' => 'h5'})
         @html.section(:class => 'block') do
            onlineClass.writeHtml(hOnline)
         end
      end
   end

   # allocation - comment
   unless hAllocation[:comment].nil?
      @html.em('Comment: ')
      @html.section(:class => 'block') do
         @html.text!(hAllocation[:comment])
      end
   end

end