Sha256: 8679ceabc614a408846f4b7e1e5dddbbd6042430b5083faf17d300f18eb068e2

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# unpack phone
# Reader - ADIwg JSON V1 to internal data structure

# History:
# 	Stan Smith 2013-12-16 original script
#   Stan Smith 2014-05-14 combine phone service types

module Md_Phone

	def self.unpack(hPhone)

		# instance classes needed in script
		intMetadataClass = InternalMetadata.new
		aPhones = Array.new

		# create a separate phone for each phone service type
		# if service is missing, default service to 'voice'
		if hPhone.has_key?('service')
			aService = hPhone['service']
		else
			aService = ['voice']
		end

		if aService.empty?
			aService = ['voice']
		end

		# if service is nil, default service to 'voice'
		aService.each do |phService|
			intPhone = intMetadataClass.newPhone

			# phone - service
			intPhone[:phoneServiceType] = phService

			# phone - name
			if hPhone.has_key?('phoneName')
				s = hPhone['phoneName']
				unless s.nil?
					intPhone[:phoneName] = s
				end
			end

			# phone - number
			if hPhone.has_key?('phoneNumber')
				s = hPhone['phoneNumber']
				unless s.nil?
					intPhone[:phoneNumber] = s
				end
			end

			aPhones << intPhone

		end

		return aPhones

	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adiwg-mdtranslator-0.10.2 lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_phone.rb