Class: CI_Address

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

Overview

History: Stan Smith 2013-08-09 original script

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ CI_Address

Returns a new instance of CI_Address.



9
10
11
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_address.rb', line 9

def initialize(xml)
  @xml = xml
end

Instance Method Details

#writeXML(hAddress) ⇒ Object



13
14
15
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
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
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_address.rb', line 13

def writeXML(hAddress)

  deliveryPoints = hAddress[:deliveryPoints].length
  eMails = hAddress[:eMailList].length

  if deliveryPoints + eMails > 0
    @xml.tag!('gmd:CI_Address') do
      # address - address
      if deliveryPoints > 0

        # address - delivery points (address lines)
        aDeliveryPoints = hAddress[:deliveryPoints]
        aDeliveryPoints.each do |myPoint|
          @xml.tag!('gmd:deliveryPoint') do
            @xml.tag!('gco:CharacterString',myPoint)
          end
        end

      elsif $showAllTags
        @xml.tag!('gmd:deliveryPoint')
      end

      # address - city
      s = hAddress[:city]
      if !s.nil?
        @xml.tag!('gmd:city') do
          @xml.tag!('gco:CharacterString',s)
        end
      elsif $showAllTags
        @xml.tag!('gmd:city')
      end

      # address - admin area (state)
      s = hAddress[:adminArea]
      if !s.nil?
        @xml.tag!('gmd:administrativeArea') do
          @xml.tag!('gco:CharacterString',s)
        end
      elsif $showAllTags
        @xml.tag!('gmd:administrativeArea')
      end

      # address - postal code
      s = hAddress[:postalCode]
      if !s.nil?
        @xml.tag!('gmd:postalCode') do
          @xml.tag!('gco:CharacterString',s)
        end
      elsif $showAllTags
        @xml.tag!('gmd:postalCode')
      end

      # address - country
      s = hAddress[:country]
      if !s.nil?
        @xml.tag!('gmd:country') do
          @xml.tag!('gco:CharacterString',s)
        end
      elsif $showAllTags
        @xml.tag!('gmd:country')
      end

      # address - email addresses
      if eMails > 0
        hAddress[:eMailList].each do |myEmail|
          @xml.tag!('gmd:electronicMailAddress') do
            @xml.tag!('gco:CharacterString',myEmail)
          end
        end
      elsif $showAllTags
        @xml.tag!('gmd:electronicMailAddress')
      end

    end
  end

end