Sha256: c162c081cffc07ba22d6f0684a4818db52bfc1eb009639e989b16df4f5fba32b

Contents?: true

Size: 1.57 KB

Versions: 7

Compression:

Stored size: 1.57 KB

Contents

# ISO <<Class>> CI_Telephone
# writer output in XML

# History:
# 	Stan Smith 2013-08-12 original script
#   Stan Smith 2014-05-14 reorganized for JSON schema 0.4.0

class CI_Telephone

	def initialize(xml)
		@xml = xml
	end

	def writeXML(aPhones)

	    # ISO requires phones to be in proper order (voice, fax)
		# Need to count phones of each type to be able to include empty tag
		voiceCount = 0
		faxCount = 0
		aPhones.each do |hPhone|
			if hPhone[:phoneServiceType].nil?
				hPhone[:phoneServiceType] = 'voice'
			end
			if hPhone[:phoneServiceType] == 'voice'
				voiceCount += 1
			end
			if hPhone[:phoneServiceType] == 'fax'
				faxCount += 1
			end
		end

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

			# phone - voice phones
			if voiceCount > 0
				aPhones.each do |hPhone|
					if hPhone[:phoneServiceType] == 'voice'
						pName = hPhone[:phoneName]
						pNumber = hPhone[:phoneNumber]
						if pName.nil?
							s = pNumber
						else
							s = pName + ': ' + pNumber
						end
						@xml.tag!('gmd:voice') do
							@xml.tag!('gco:CharacterString',s)
						end
					end
				end
			elsif $showAllTags
				@xml.tag!('gmd:voice')
			end

			# phone - fax phones
			if faxCount > 0
				aPhones.each do |hPhone|
					if hPhone[:phoneServiceType] == 'fax'
						pName = hPhone[:phoneName]
						pNumber = hPhone[:phoneNumber]
						if pName.nil?
							s = pNumber
						else
							s = pName + ': ' + pNumber
						end
						@xml.tag!('gmd:facsimile') do
							@xml.tag!('gco:CharacterString',s)
						end
					end
				end
			elsif $showAllTags
				@xml.tag!('gmd:facsimile')
			end
		end

	end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
adiwg-mdtranslator-0.10.2 lib/adiwg/mdtranslator/writers/iso/classes/class_telephone.rb
adiwg-mdtranslator-0.9.0 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb
adiwg-mdtranslator-0.8.6 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb
adiwg-mdtranslator-0.8.5 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb
adiwg-mdtranslator-0.8.2 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb
adiwg-mdtranslator-0.8.1 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb
adiwg-mdtranslator-0.8.0 lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_telephone.rb