Module: ADIWG::Mdtranslator::Readers::MdJson::Algorithm

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_algorithm.rb

Class Method Summary collapse

Class Method Details

.unpack(hAlgorithm, responseObj, inContext = nil) ⇒ Object



16
17
18
19
20
21
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
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_algorithm.rb', line 16

def self.unpack(hAlgorithm, responseObj, inContext = nil)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hAlgorithm.empty?
      @MessagePath.issueWarning(970, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = .new
   intAlgorithm = intMetadataClass.newAlgorithm

   outContext = 'algorithm'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   # algorithm - citation (required)
   if hAlgorithm.has_key?('citation')
      unless hAlgorithm['citation'].empty?
         hReturn = Citation.unpack(hAlgorithm['citation'], responseObj, outContext)
         unless hReturn.nil?
            intAlgorithm[:citation] = hReturn
         end
      end
   end
   if intAlgorithm[:citation].empty?
      @MessagePath.issueWarning(971, responseObj, inContext)
   end

   # algorithm - description (required)
   if hAlgorithm.has_key?('description')
      unless hAlgorithm['description'] == ''
         intAlgorithm[:description] = hAlgorithm['description']
      end
   end
   if intAlgorithm[:description].nil?
      @MessagePath.issueWarning(972, responseObj, inContext)
   end

   return intAlgorithm

end