Class: ADIWG::Mdtranslator::Writers::Simple_html::Html_Allocation

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/simple_html/sections/html_allocation.rb

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ Html_Allocation



18
19
20
# File 'lib/adiwg/mdtranslator/writers/simple_html/sections/html_allocation.rb', line 18

def initialize(html)
   @html = html
end

Instance Method Details

#writeHtml(hAllocation) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/adiwg/mdtranslator/writers/simple_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.div do
         @html.div(hResponsibility[:roleName], 'class' => 'h5')
         @html.div(:class => 'block') do
            responsibilityClass.writeHtml(hResponsibility)
         end
      end
   end

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

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

end