Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_Medium

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_medium.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_Medium

Returns a new instance of MD_Medium.



24
25
26
27
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_medium.rb', line 24

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
end

Instance Method Details

#writeXML(hMedium) ⇒ Object



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/iso19115_2/classes/class_medium.rb', line 29

def writeXML(hMedium)

   # classes used
   codelistClass = MD_Codelist.new(@xml, @hResponseObj)

   @xml.tag!('gmd:MD_Medium') do

      # medium - name {MD_MediumNameCode}
      hIdentifier = hMedium[:identifier]
      s = nil
      unless hIdentifier.empty?
         s = hIdentifier[:identifier]
         unless s.nil?
            @xml.tag!('gmd:name') do
               codelistClass.writeXML('gmd', 'iso_mediumName', s)
            end
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:name')
      end

      # medium - density {MB}
      s = hMedium[:density]
      unless s.nil?
         @xml.tag!('gmd:density') do
            @xml.tag!('gco:Real', s.to_s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:density')
      end

      # medium density units
      s = hMedium[:units]
      unless s.nil?
         s = s.downcase
         @xml.tag!('gmd:densityUnits') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:densityUnits')
      end

      # medium - volumes
      s = hMedium[:numberOfVolumes]
      unless s.nil?
         @xml.tag!('gmd:volumes') do
            @xml.tag!('gco:Integer', s.to_s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:volumes')
      end

      # medium - medium format code [] {MD_MediumFormatCode}
      aCode = hMedium[:mediumFormat]
      aCode.each do |code|
         @xml.tag!('gmd:mediumFormat') do
            codelistClass.writeXML('gmd', 'iso_mediumFormat', code)
         end
      end
      if aCode.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:mediumFormat')
      end

      # medium - note
      s = hMedium[:note]
      unless s.nil?
         @xml.tag!('gmd:mediumNote') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:mediumNote')
      end

   end # gmd:MD_Medium
end