Class: Yardi::Utils::PhoneParser

Inherits:
Object
  • Object
show all
Defined in:
lib/yardi/utils/phone_parser.rb

Class Method Summary collapse

Class Method Details

.parse(phone) ⇒ Array<String>

A single prospect/resident can have have 0 to many <Phone> nodes, so prospect/resident can have three different types:

nil if there's no phone included
a Hash representing a single phone number if there's one phone
an Array if there are multiple phones

Parameters:

  • phone (nil|Hash|Array)

Returns:

  • (Array<String>)

    if at least one ‘PhoneNumber` exists, or nil otherwise.



14
15
16
17
18
19
20
# File 'lib/yardi/utils/phone_parser.rb', line 14

def self.parse(phone)
  if phone.is_a?(Array)
    phone.map { |ph| ph['PhoneNumber'] }.compact
  elsif phone && phone['PhoneNumber']
    [phone['PhoneNumber']]
  end
end