Sha256: 764759b62660a8beb8b8fee451522a16548e87b1eff596c35d127e54f244935a

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

# unpack vector object
# Reader - ADIwg JSON to internal data structure

# History:
#  Stan Smith 2018-02-19 refactored error and warning messaging
# 	Stan Smith 2016-10-19 original script

module ADIWG
   module Mdtranslator
      module Readers
         module MdJson

            module VectorObject

               def self.unpack(hVecObj, responseObj)

                  # return nil object if input is empty
                  if hVecObj.empty?
                     responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: vector object is empty'
                     return nil
                  end

                  # instance classes needed in script
                  intMetadataClass = InternalMetadata.new
                  intVecObj = intMetadataClass.newVectorObject

                  # vector object - object type (required)
                  if hVecObj.has_key?('objectType')
                     unless hVecObj['objectType'] == ''
                        intVecObj[:objectType] = hVecObj['objectType']
                     end
                  end
                  if intVecObj[:objectType].nil?
                     responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: vector object type is missing'
                     responseObj[:readerExecutionPass] = false
                     return nil
                  end

                  # vector object - object count
                  if hVecObj.has_key?('objectCount')
                     unless hVecObj['objectCount'] == ''
                        intVecObj[:objectCount] = hVecObj['objectCount']
                     end
                  end

                  return intVecObj

               end

            end

         end
      end
   end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.13.0 lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb
adiwg-mdtranslator-2.12.0 lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb
adiwg-mdtranslator-2.12.0.pre lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb
adiwg-mdtranslator-2.10.0 lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb