15
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
59
60
61
62
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_measure.rb', line 15
def self.unpack(hMeasure, responseObj, inContext = nil)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hMeasure.empty?
@MessagePath.issueWarning(540, responseObj, inContext)
return nil
end
intMetadataClass = InternalMetadata.new
intMeasure = intMetadataClass.newMeasure
if hMeasure.has_key?('type')
unless hMeasure['type'] == ''
type = hMeasure['type']
if %w{ distance length vertical angle measure scale }.one? {|word| word == type}
intMeasure[:type] = hMeasure['type']
else
@MessagePath.issueError(541, responseObj, inContext)
end
end
end
if intMeasure[:type].nil? || intMeasure[:type] == ''
@MessagePath.issueError(542, responseObj, inContext)
end
if hMeasure.has_key?('value')
intMeasure[:value] = hMeasure['value']
end
if intMeasure[:value].nil? || intMeasure[:value] == ''
@MessagePath.issueError(543, responseObj, inContext)
end
if hMeasure.has_key?('unitOfMeasure')
intMeasure[:unitOfMeasure] = hMeasure['unitOfMeasure']
end
if intMeasure[:unitOfMeasure].nil? || intMeasure[:unitOfMeasure] == ''
@MessagePath.issueError(544, responseObj, inContext)
end
return intMeasure
end
|