Module: Adiwg_TemporalElement

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_temporalElement.rb

Class Method Summary collapse

Class Method Details

.unpack(hTempElement) ⇒ Object



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
63
64
65
66
67
68
69
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_temporalElement.rb', line 20

def self.unpack(hTempElement)

  # instance classes needed in script
  intMetadataClass = .new
  aIntTempElements = Array.new

  # temporal element - date
  if hTempElement.has_key?('date')
    aDates = hTempElement['date']
    unless aDates.empty?
      aDates.each do |s|
        intTempEle = intMetadataClass.newTemporalElement
        intTempEle[:date] = Adiwg_DateTime.unpack(s)
        aIntTempElements << intTempEle
      end
    end
  end

  # temporal element - time instant
  if hTempElement.has_key?('timeInstant')
    aTimeInst = hTempElement['timeInstant']
    unless aTimeInst.empty?
      aTimeInst.each do |hTimeInst|
        if hTimeInst.has_key?('timePosition')
          s = hTimeInst['timePosition']
          if s != ''
            intTempEle = intMetadataClass.newTemporalElement
            intTempEle[:timeInstant] = Adiwg_TimeInstant.unpack(hTimeInst)
            aIntTempElements << intTempEle
          end
        end
      end
    end
  end

  # temporal element - time period
  if hTempElement.has_key?('timePeriod')
    aTimePeriod = hTempElement['timePeriod']
    unless aTimePeriod.empty?
      aTimePeriod.each do |hTimePeriod|
        intTempEle = intMetadataClass.newTemporalElement
        intTempEle[:timePeriod] = Adiwg_TimePeriod.unpack(hTimePeriod)
        aIntTempElements << intTempEle
      end
    end
  end

  return aIntTempElements

end