Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_LegalConstraints

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_LegalConstraints

Returns a new instance of MD_LegalConstraints.



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

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

Instance Method Details

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

def writeXML(hConstraint)

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

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

      # constraints - use limitation []
      aUse = hConstraint[:useLimitation]
      aUse.each do |useCon|
         @xml.tag!('gmd:useLimitation') do
            @xml.tag!('gco:CharacterString', useCon)
         end
      end
      if aUse.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:useLimitation')
      end

      hLegalCon = hConstraint[:legalConstraint]

      # legal constraints - access constraints
      aAccess = hLegalCon[:accessCodes]
      aAccess.each do |code|
         @xml.tag!('gmd:accessConstraints') do
            codelistClass.writeXML('gmd', 'iso_restriction', code)
         end
      end
      if aAccess.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:accessConstraints')
      end

      # legal constraints - use constraints
      aUse = hLegalCon[:useCodes]
      aUse.each do |code|
         @xml.tag!('gmd:useConstraints') do
            codelistClass.writeXML('gmd', 'iso_restriction', code)
         end
      end
      if aUse.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:useConstraints')
      end

      # legal constraints - other constraints
      aOther = hLegalCon[:otherCons]
      aOther.each do |con|
         @xml.tag!('gmd:otherConstraints') do
            @xml.tag!('gco:CharacterString', con)
         end
      end
      if aOther.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:otherConstraints')
      end

   end # gmd:MD_LegalConstraints tag
end