Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_DigitalTransferOptions

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_DigitalTransferOptions

Returns a new instance of MD_DigitalTransferOptions.



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

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

Instance Method Details

#writeXML(hOption) ⇒ 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
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_transferOptions.rb', line 29

def writeXML(hOption)

   # classes used
   olResClass = CI_OnlineResource.new(@xml, @hResponseObj)
   medClass = MD_Medium.new(@xml, @hResponseObj)

   outContext = 'transfer option'

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

      # digital transfer options - units of distribution
      s = hOption[:unitsOfDistribution]
      unless s.nil?
         @xml.tag!('gmd:unitsOfDistribution') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:unitsOfDistribution')
      end

      # digital transfer options - transfer size {MB}
      s = hOption[:transferSize]
      unless s.nil?
         @xml.tag!('gmd:transferSize') do
            @xml.tag!('gco:Real', s.to_s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:transferSize')
      end

      # digital transfer options - online [] {CI_OnlineResource}
      aOnTranOpts = hOption[:onlineOptions]
      aOnTranOpts.each do |hOlOption|
         @xml.tag!('gmd:onLine') do
            olResClass.writeXML(hOlOption, outContext)
         end
      end
      if aOnTranOpts.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:onLine')
      end

      # digital transfer options - offline {MD_Medium}
      aOffTranOpt = hOption[:offlineOptions]
      unless aOffTranOpt.empty?
         hOffTranOpt = aOffTranOpt[0]
         unless hOffTranOpt.empty?
            @xml.tag!('gmd:offLine') do
               medClass.writeXML(hOffTranOpt)
            end
         end
      end
      if aOffTranOpt.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:offLine')
      end

   end # gmd:MD_DigitalTransferOptions tag
end