Class: 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) ⇒ MD_LegalConstraints

Returns a new instance of MD_LegalConstraints.



12
13
14
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_legalConstraints.rb', line 12

def initialize(xml)
  @xml = xml
end

Instance Method Details

#writeXML(hLegalCons) ⇒ Object



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
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_legalConstraints.rb', line 16

def writeXML(hLegalCons)

  # classes used
  restrictionCode = MD_RestrictionCode.new(@xml)

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

    # legal constraints - access constraints
    aAccessCodes = hLegalCons[:accessCodes]
    if !aAccessCodes.empty?
      aAccessCodes.each do |code|
        @xml.tag!('gmd:accessConstraints') do
          restrictionCode.writeXML(code)
        end
      end
    elsif $showAllTags
      @xml.tag!('gmd:accessConstraints')
    end

    # legal constraints - use constraints
    aUseCodes = hLegalCons[:useCodes]
    if !aUseCodes.empty?
      aUseCodes.each do |code|
        @xml.tag!('gmd:useConstraints') do
          restrictionCode.writeXML(code)
        end
      end
    elsif $showAllTags
      @xml.tag!('gmd:useConstraints')
    end

    # legal constraints - other constraints
    aOtherCons = hLegalCons[:otherCons]
    if !aOtherCons.empty?
      aOtherCons.each do |con|
        @xml.tag!('gmd:otherConstraints') do
          @xml.tag!('gco:CharacterString',con)
        end
      end
    elsif $showAllTags
      @xml.tag!('gmd:otherConstraints')
    end

  end

end