Class: CI_Contact

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ CI_Contact

Returns a new instance of CI_Contact.



16
17
18
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_contact.rb', line 16

def initialize(xml)
	@xml = xml
end

Instance Method Details

#getContact(contactID) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_contact.rb', line 72

def getContact(contactID)

	# find contact in contact array and return the hash
	$intContactList.each do |hContact|
		if hContact[:contactID] == contactID
			return hContact
		end
	end

	return {}

end

#writeXML(hContact) ⇒ Object



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

def writeXML(hContact)

	# classes used in MD_Metadata
	pBookClass = CI_Telephone.new(@xml)
	addClass = CI_Address.new(@xml)
	resourceClass = CI_OnlineResource.new(@xml)

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

		# contact - phone list - all services
		aPhones = hContact[:phones]
		if !aPhones.empty?
			@xml.tag!('gmd:phone') do
				pBookClass.writeXML(aPhones)
			end
		elsif $showAllTags
			@xml.tag!('gmd:phone')
		end

		# contact - address
		hAddress = hContact[:address]
		if !hAddress.empty?
			@xml.tag!('gmd:address') do
				addClass.writeXML(hAddress)
			end
		elsif $showAllTags
			@xml.tag!('gmd:address')
		end

		# contact - online resource
		aResource = hContact[:onlineRes]
		if !aResource.empty?
			@xml.tag!('gmd:onlineResource') do
				resourceClass.writeXML(aResource[0])
			end
		elsif $showAllTags
			@xml.tag!('gmd:onlineResource')
		end

		# contact - contact instructions
		s = hContact[:contactInstructions]
		if !s.nil?
			@xml.tag!('gmd:contactInstructions') do
				@xml.tag!('gco:CharacterString',hContact[:contactInstructions])
			end
		elsif $showAllTags
			@xml.tag!('gmd:contactInstructions')
		end

	end
end