Module: Adiwg_Phone

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_phone.rb

Overview

History: Stan Smith 2013-12-16 original script

Stan Smith 2014-05-14 combine phone service types

Class Method Summary collapse

Class Method Details

.unpack(hPhone) ⇒ Object



10
11
12
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
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_phone.rb', line 10

def self.unpack(hPhone)

  # instance classes needed in script
  intMetadataClass = .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